Hi
I have the following tables/relations:
contact has a district that has a district manager
contact table has a district id
district table has an auth_user id
when editing a contact I want my dropdown to display my district number
and the name of the manager.
How would I specify my validator on contact.districtId to display the
name of the manager from the auth_user table?
I've tried:
district = db.define_table('district',
Field('districtId', 'id'),
Field('districtNumber', 'integer', required=True,
unique=True, label='District Number'),
Field('name', length=50, required=True, unique=True),
Field('salesmanId', db.auth_user, required=True,
label='District Manager'),
Field('includeInArAging', 'boolean', required=True,
label='Include in A/R Aging'),
Field('regionNumber', 'integer', label='Region Number'))
district.districtNumber.requires = [IS_NOT_EMPTY(),
IS_NOT_IN_DB(db, 'district.districtNumber')]
district.name.requires = [IS_NOT_EMPTY(),
IS_NOT_IN_DB(db, 'district.name')]
district.salesmanId.requires = IS_IN_DB(db, db.auth_user,
'%(first_name)s %(last_name)s')
contact = db.define_table('contact',
Field('contactId', 'id'),
Field('company', length=50),
Field('title', length=20),
Field('firstName', length=25, label='First Name'),
Field('lastName', length=25, label='Last Name'),
Field('address1', length=50, label='Address'),
Field('address2', length=50, label=''),
Field('city', length=30),
Field('state', length=2),
Field('zipCode', length= 10, label='ZIP Code'),
Field('county', length=30),
Field('districtId', db.district, required=True,
label='District'),
Field('phone1', length=25),
Field('phone2', length=25),
Field('phone3', length=25),
Field('mobilePhone', length=25, label='Mobile'),
Field('pager', length=25),
Field('homePhone', length=25, label='Home'),
Field('fax', length=25),
Field('emailAddress', length=10, label='Email'),
Field('notes', 'text'),
Field('priceListDelivery', length=10, label='Price Lists Via'))
contact.districtId.requires = IS_IN_DB(db, 'district.id',
'%(salesmanId.first_name)s', zero=('select district'))
...but, I get an error on the salesmanId.first_name
I believe I have a fundamental misunderstanding of the ways in which
this works. Any pointers would be appreciated...
-Jim