try form.vars.sharedServiceID=sharedServiceID On Sunday, March 17, 2013 3:13:58 AM UTC-4, Alex Glaros wrote: > > I'm trying to automatically populate child FK field "sharedServiceID" > using the controller below, but the field gets filled with "none" > > Do you see any flaw in the controller format below? > > Thanks, > > Alex Glaros > > > > PARENT TABLE > > db.define_table('SharedService', > Field('shortSharedServiceTitle', 'string', label='Title')) > ##------------------------ > > CHILD TABLE > > db.define_table('SharedServicePartnerIntersection', > Field('*sharedServiceID*', 'reference SharedService', > writable=False,readable=False), > > ##------------------------ > db.SharedServicePartnerIntersection.sharedServiceID.requires = > IS_IN_DB(db, db.SharedService.id, > '%(shortSharedServiceTitle)s',zero=T('choose one')) > db.SharedServicePartnerIntersection['_plural'] = 'Partner List' > > CONTROLLER > > def add_partner(): > > form=SQLFORM.factory(db.SharedService,db.SharedServicePartnerIntersection) > if form.process().accepted: > *sharedServiceID* = > db.SharedService.insert(**db.SharedService._filter_fields(form.vars)) > form.vars.SharedService=*sharedServiceID* > > db.SharedServicePartnerIntersection.insert(**db.SharedServicePartnerIntersection._filter_fields(form.vars)) > response.flash='Thanks for adding a shared service partner' > return dict(form=form) > > also tried this > > def add_partner(): > > form=SQLFORM.factory(db.SharedService,db.SharedServicePartnerIntersection) > if form.process().accepted: > sharedServiceID = > db.SharedService.insert(**db.SharedService._filter_fields(form.vars)) > form.vars.SharedService=sharedServiceID > *sharedServiceID = * > db.SharedServicePartnerIntersection.insert(**db.SharedServicePartnerIntersection._filter_fields(form.vars)) > response.flash='Thanks for adding a shared service partner' > return dict(form=form) > >
-- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.