Hi,
I am wondering how this solution (single form with linked tables) can
be used for updates (in addition to creates)?.
Thanks,
Carlos
On Dec 6, 4:32 am, DenesL <
denes1...@yahoo.ca> wrote:
> True, only restriction is no common field names.
> I have added this to the book.
>
> On Dec 5, 11:05 pm, mdipierro <
mdipie...@cs.depaul.edu> wrote:
>
>
>
>
>
>
>
> > 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 theform.
>
> > On Dec 5, 9:41 pm, DenesL <
denes1...@yahoo.ca> wrote:
>
> > > This only works fortablesthat do not have field names in common
> > > and have no references between them.
>
> > > On Oct 16, 9:57 am, mdipierro <
mdipie...@cs.depaul.edu> wrote:
>
> > > > It often happens that you have twotables(for example 'client' and
> > > > 'address' which arelinkedtogether by a reference and you want to
> > > > create asingleformthat 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)
> > > > ifform.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 theform'
> > > > return dict(form=form)
>
> > > > Notice the SQLFORM.factory (it makes ONEformusing public fields from
> > > > bothtablesand inherits their validators too).
> > > > Onformaccepts this does two inserts (some data in one table and some