Think you should read the book section about more then one form per page
and about component. What you want to do is hide a second form in the same
page... Those form should be embeded in the page as component en then you
have to write the proper logic in ajax and jQuery to make appears your
second form when the first set of field have been completed...

Also you can have a look at : http://dev.s-cubism.com/web2py_plugins

Many fancy plugins for web2py that exist and make your life easier when you
need it.

Richard

On Mon, May 14, 2012 at 10:42 AM, Alec Taylor <[email protected]>wrote:

> Is it possible to have a nested CRUD form?
>
> From a logical perspective it sometime doesn't make sense, for
> example, to add an Address before you add a Customer.
>
> db.define_table('address',
>    Field('line1','string', required=True),
>    Field('line2','string'),
>    Field('suburb','string', required=True),
>    Field('post_code','integer'),
>    Field('email','string')
> )
>
> db.address.post_code.requires = IS_INT_IN_RANGE(0000, 9999)
> db.address.email.requires        = IS_EMAIL()
>
> db.define_table('customer',
>    Field('name', 'string', required=True, unique=True),
>    Field('locations', 'list:reference db.address', required=True),
>    Field('comment', 'string')
> ) # quick aside: how would I ensure there isn't another customer with
> same name+location?
>
> db.address.requires = IS_IN_DB(db, db.address, '%(line1)s + ', " +
> %(suburb)s', multiple=True)
>
> So if I could generate one form that allows you to create a customer,
> complete with address, the management would become much more logical.
>
> How would I generate this?
>
> Thanks for all suggestions,
>
> Alec Taylor
>
> BTW: It would still be useful however to still be able to pick from
> the list already in the db, but to just have an "Add" that will
> rolldown with javascript, and which will open by default if that field
> is empty (and .requires not to be).
>

Reply via email to