No field names in comment yes. References between them is not a problem as long the reference fields are not writable and readable when generating the form.
On Dec 5, 9:41 pm, DenesL <[email protected]> wrote: > This only works for tables that do not have field names in common > and have no references between them. > > On Oct 16, 9:57 am, mdipierro <[email protected]> wrote: > > > It often happens that you have two tables (for example 'client' and > > 'address' which are linked together by a reference and you want to > > create a single form that allows to insert info about one client and > > its default address. Here is how: > > > model: > > > db.define_table('client', > > Field('name')) > > db.define_table('address', > > Field('client',db.client,writable=False,readable=False), > > Field('street'),Field('city')) > > > controller: > > > def register(): > > form=SQLFORM.factory(db.client,db.address) > > if form.accepts(request.vars): > > id = db.client.insert(**db.client._filter_fields(form.vars)) > > form.vars.client=id > > id = db.address.insert(**db.address._filter_fields(form.vars)) > > response.flash='Thanks for filling the form' > > return dict(form=form) > > > Notice the SQLFORM.factory (it makes ONE form using public fields from > > both tables and inherits their validators too). > > On form accepts this does two inserts (some data in one table and some > > data in the other). > > > Massimo > >

