In web2py, say I have modified the default auth_user table by adding a field called 'agent_code'. This field should include values from another table:
auth_table = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
...more fields here...,
Field('auth_age_cod', length=512,default=None))
auth_table.auth_age_cod.requires = \
IS_IN_DB(db, db.agea.agea_cod,
'%(agea_cod)s - %(agea_name)s',
error_message='Agent not in DB')
I want users to be able to identify themselves as agents during registration.
The user registration form now shows the dropbox to allow for agent selection, but includes a blank option at the start. For some reasons this is not acceptable in our system.
After investigating the source code for the validator, I found that the IS_IN_DB validator has a parameter called 'zero'. This is by default set to '' (empty string) and creates a blank option in the droplist.
So, to remove the blank option, change the validator to:
IS_IN_DB(db, db.agea.agea_cod,
'%(agea_cod)s - %(agea_name)s',
error_message='Agent not in DB',
zero=None)