Thanks Anthony,
I want to explicitly link the tables as you described above. Do I put
this code in in the DB_WIZARD.PY file?
If so how would I modify it. Everything I try produces an error on
save. Here are the two tables in question.
db.define_table('t_ab_distribution',
Field('f_distributionname', type='string', unique=True,
label=T('Distributionname')),
Field('f_location1', type='string',
label=T('Location1')),
Field('f_location2', type='string',
label=T('Location2')),
Field('f_location3', type='string',
label=T('Location3')),
Field('f_location4', type='string',
label=T('Location4')),
Field('f_distributiondate', type='date',
label=T('Distributiondate')),
Field('f_contact1', type='string',
label=T('Contact1')),
Field('f_phone1', type='string',
label=T('Phone1')),
Field('f_contact2', type='string',
label=T('Contact2')),
Field('f_phone2', type='string',
label=T('Phone2')),
Field('f_contact3', type='string',
label=T('Contact3')),
Field('f_phone3', type='string',
label=T('Phone3')),
Field('f_contact4', type='string',
label=T('Contact4')),
Field('f_phone4', type='string',
label=T('Phone4')),
auth.signature,
format='%(f_distributionname)s',
migrate=settings.migrate)
db.define_table('t_ab_distribution_archive',db.t_ab_distribution,Field('current_record','reference
t_ab_distribution',readable=False,writable=False))
###############################
db.define_table('t_ab_recipient',
Field('f_recipient_name', type='string',
label=T('Recipient Name')),
Field('f_recipient_phone', type='string',
label=T('Recipient Phone')),
Field('f_recipient_number', type='string',
label=T('Recipient Number')),
Field('f_team_num', type='string',
label=T('Team Num')),
Field('f_gps_coord', type='string',
label=T('Gps Coord')),
Field('f_recipients_photo', type='upload',
label=T('Recipients Photo')),
Field('f_distribution_name', type='string',
label=T('Distribution Name')),
Field('f_location_spesific', type='string',
label=T('Location Spesific')),
auth.signature,
format='%(f_recipient_name)s',
migrate=settings.migrate)
db.define_table('t_ab_recipient_archive',db.t_ab_recipient,Field('current_record','reference
t_ab_recipient',readable=False,writable=False))
On Nov 19, 11:42 am, Anthony <[email protected]> wrote:
> You could do:
>
> db.t_ab_recipient.f_distribution_name.requires = IS_IN_DB(db,
> 't_ab_distribution.f_distributionname')
>
> Seehttp://web2py.com/book/default/chapter/07#Database-Validators.
>
> Instead, though, you might want to explicitly link the two tables:
>
> db.define_table('t_ab_distribution',
> Field('f_distributionname'),
> format='%(f_distributionname)')
>
> db.define_table('t_ab_recipient',
> Field('f_distribution', db.t_ab_distribution))
>
> That will automatically add an IS_IN_DB validator to f_distribution, and it
> will display the f_distributionname in the list due to the
> format='%(f_distributionname)'.
>
> Anthony
>
>
>
>
>
>
>
> On Saturday, November 19, 2011 9:05:21 AM UTC-5, EdgarAllenPoe wrote:
>
> > Can some one show me what the code would look like to accomplish the
> > following:
>
> > Create a drop down list for field A
> > that will be populated by field B
>
> > A. db.t_ab_recipient.f_distribution_name
>
> > B. db.t_ab_distribution.f_distributionname
>
> > Any help would be appreciated.