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