Vineet,

 I wonder if this is what you want?

I use this all the time. I have company info in a table and address in
another, and my form contains company and address fields.

db.define_table('company',
    Field('name'),
    Field('addressid', db.address),
    migrate='company.table')
db.define_table('address',
    Field('street'),
    Field('city'),
    Field('state')
    Field('zip'),
    migrate='address.table')

In the controller: (company.py):

def newcompany():
     'Get the data for a new company'
    fields = 'name street city state zip'.split(' ')
    form = SQLFORM.factory(db.address,db.company, fields=fields,
                           formstyle='divs', submit_button='Save
Company')

    if form.accepts(request.vars, session):
        coid =
db.company.insert(**db.company._filter_fields(form.vars))
        addrid =
db.address.insert(**db.address._filter_fields(form.vars))
        db(db.company.id == coid).update(addrid = addrid)
    elif form.errors

Reply via email to