Did you show the correct controller code? Your form is define as a SQLTABLE 
(rather than SQLFORM), and the table argument is db.suppliers, not 
db.purchase_orders.

Anthony

On Monday, August 29, 2011 7:33:25 AM UTC-4, Cliff wrote:
>
> Not sue that would help. 
>
> The insert goes into purchase_orders, not supplier_contacts. 
>
> On Aug 26, 4:16 pm, Anthony <[email protected]> wrote: 
> > Does it work if you set db.supplier_contacts.supplier_id.writable = True 
> in 
> > the controller function? 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Friday, August 26, 2011 11:12:31 AM UTC-4, Cliff wrote: 
> > 
> > > Massimo, 
> > 
> > > Thank you. 
> > 
> > > Of course. 
> > 
> > > Here are are the real table defs: 
> > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
>
> > > ++++++++++ 
> > > db.define_table('purchase_orders', 
> > >     Field('issue_date', 'date'), 
> > >     Field('number', length=24, requires=IS_NOT_EMPTY(), 
> > >           required=True, notnull=True, comment='Required'), 
> > >     Field('supplier', db.suppliers), 
> > >     Field('shipto', db.locations, label='Ship To'), 
> > >     Field('billto', db.locations, label='Bill To'), 
> > >     Field('del_terms', db.del_terms, label='Delivery Terms'), 
> > >     Field('currency', db.currencies), 
> > >     Field('pmt_terms', db.pmt_terms, label='Payment Terms'), 
> > >     Field('project_no', length=12, label='Project Number'), 
> > >     Field('taxable', 'list:string', default='No'), 
> > >     Field('po_contact', db.contacts, 
> > >             label='Purchase Order Contact'), 
> > >     Field('ap_contact',  db.contacts, 
> > >             label='Accounts Payable Contact'), 
> > >     Field('vendor_rep',  db.contacts, 
> > >             label='Vendor Representative'), 
> > >     Field('documentation_required', 'list:reference documentation', 
> > >             comment='Click to select.  Use Ctrl key for multiple 
> > > selection.') 
> > >     ) 
> > > db.purchase_orders.taxable.requires = IS_IN_SET(['Yes', 'No']) 
> > > db.purchase_orders.shipto.requires = IS_IN_DB(db, db.locations.id, '% 
> > > (name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.billto.requires = IS_IN_DB(db, db.locations.id, '% 
> > > (name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.supplier.requires = IS_IN_DB(db, db.suppliers.id, 
> '% 
> > > (name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.del_terms.requires = IS_IN_DB(db, db.del_terms.id, 
> > > '%(name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.currency.requires = IS_IN_DB(db, db.currencies.id, 
> > > '%(name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.pmt_terms.requires = IS_IN_DB(db, db.pmt_terms.id, 
> > > '%(name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.po_contact.requires = IS_IN_DB( 
> > >         db(), db.contacts.id, '%(first_name)s, %(middle_name)s, % 
> > > (last_name)s, %(generation)s ', 
> > >         zero='Choice required') 
> > > db.purchase_orders.ap_contact.requires = IS_IN_DB( 
> > >         db(), db.contacts.id, '%(first_name)s', 
> > >         zero='Choice required') 
> > > db.purchase_orders.vendor_rep.requires = IS_IN_DB( 
> > >         db(), db.supplier_contacts.id, '%(first_name)s', 
> > >         zero='Choice required') 
> > 
> > > db.define_table('suppliers', 
> > >     Field('name', length=256, required=True, notnull=True), 
> > >     Field('address', length=64), 
> > >     Field('address_2', length=64), 
> > >     Field('city', length=32), 
> > >     Field('state', length=24), 
> > >     Field('zip', length=18), 
> > >     Field('website', length=512, requires=IS_URL()), 
> > >     format = '%(name)s' 
> > >     ) 
> > 
> > > db.define_table( 
> > >     'supplier_contacts', 
> > >     Field('supplier_id', db.suppliers), 
> > >     Field('first_name', length=32, required=True, notnull=True), 
> > >     Field('middle_name', length=32), 
> > >     Field('last_name', length=32, required=True, notnull=True), 
> > >     Field('generation', length=16), 
> > >     Field('email', length=512, 
> > >           requires=IS_EMPTY_OR(IS_EMAIL('invalid email'))), 
> > >     Field('mobile', length=18, label='Mobile phone'), 
> > >     Field('land_line', length=18), 
> > >     Field('fax', length=18), 
> > >     format='%(first_name)s, %(middle_name)s, %(last_name)s, % 
> > > (generation)s' 
> > >     ) 
> > > db.supplier_contacts.supplier_id.requires = IS_IN_DB( 
> > >     db, db.suppliers.id, '%(name)s', zero='Choose' 
> > >     ) 
> > > db.supplier_contacts.supplier_id.readable = False 
> > > db.supplier_contacts.supplier_id.writable = False 
> > 
> > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
>
> > > ++++++++++++++++++++++++++++++++++ 
> > 
> > > This is the actual call from the controller: 
> > >             # we already know the supplier_id and vendor_rep 
> > >             hidden['supplier']=supplier_id 
> > >             hidden['vendor_rep'=vendor_rep 
> > >             field_lst = 'issue_date number shipto billto del_terms 
> > > currency pmt_terms project_no taxable po_contact ap_contact 
> > > documentation_required'.split(' ') 
> > >             form = SQLTABLE(db.suppliers, fields=field_lst, 
> > > hidden=hidden) 
> > 
> > > On Aug 26, 8:39 am, Massimo Di Pierro <[email protected]> 
> > > wrote: 
> > > > Can I see the model? 
> > 
> > > > On Aug 26, 4:43 am, Cliff <[email protected]> wrote: 
> > 
> > > > > I use SQLFORM something like this: 
> > 
> > > > > fields = 'dog_name dog_weight dog_birtdate'.split(' ') 
> > > > > hidden = {'dog_owner' : some_known_value} # We already know who the 
>
> > > > > owner is 
> > > > > SQLFORM(db.dogs, fields=fields, hidden=hidden) 
> > 
> > > > > The hidden fields are on the form.  When I submit the form, they 
> are 
> > > > > in request.vars, but SQLFORM does not insert them in the database. 
> > 
> > > > > Is this the way it's supposed to work or do I have a bug? 
> > 
> > > > > Thanks, 
> > > > > Cliff Kachinske

Reply via email to