Hi
I have a situation where I have a field that is referencing a field in
another table. I added the .requires = IS_IN_DB to get CRUD to create
the dropdown for selection of the field. But, that's not really what I
want. I would like the dropdown to get generated in CRUD, but for the
field to not be required. Here is the code that I have now,
rebateClassId is the field I'm talking about. I want the dropdown
generated but it can be left blank.
productClass = db.define_table('productClass',
Field('productClassId', 'id'),
Field('productClass', length=4, required=True,
unique=True, label='Product Class'),
Field('name', length=50, required=True, unique=True),
Field('tracksTons', 'boolean', required=True, label='Tracks
Tons'),
Field('rebateClassId', 'reference productClass',
label='Rebate Class'),
Field('rebateSequence', 'integer', label='Rebate Sequence'),
Field('productClassGroupId', db.productClassGroup,
label='Product Class Group'))
productClass.productClass.requires = [IS_NOT_EMPTY(),
IS_NOT_IN_DB(db, 'productClass.productClass')]
productClass.name.requires = [IS_NOT_EMPTY(),
IS_NOT_IN_DB(db, 'productClass.name')]
productClass.rebateClassId.requires = IS_IN_DB(db,
db.productClass.productClassId,
'%(name)s',
zero=('select rebate
class'))
productClass.productClassGroupId.requires = IS_IN_DB(db,
db.productClassGroup.productClassGroupId,
'%(name)s',
zero=('select product class group'))
--
Jim Steil
VP of Information Technology
Quality Liquid Feeds, Inc.
608.935.2345 office
608.341.9896 cell