i think you should refer it to db.brands.id. e.g.
db.define_table('brands',
Field('id_01', unique = True),
Field('name'),
format='%(name)s')
db.define_table('products',
Field('code', unique=True),
Field('description'),
Field('brand_id_01', 'reference brands', requires =
IS_IN_DB(db, db.brands.id, '%(name)s')))
it requires the table products to refer to brands id field not id_01 in
table brands. not sure what do you want to achieve in here, i think you can
make conditional requires.
e.g. (not tested)
if 'crm' in request.function :
db.products.brand_id_01.requires = IS_IN_DB(db, db.brands.id,
'%(id_01)s')
else:
db.products.brand_id_01.requires = IS_IN_DB(db, db.brands.id,
'%(name)s')
my point is the reference field in products table is refer to the id field
on brands, and for the field represented on drop down list is base on the
function, if it contain 'crm' it will show the brands.id_01, other function
will show the name.
ref:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-representation
best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.