Hi, I have a field in table 'expenses' defined as:
db.define_table('expenses',
                Field('gang', db.gangs, required=True, notnull=True),
                ...
                Field('payer', db.gang_users, label=T('Payer')),
                ...

Table gang_users has a format like:

db.define_table('gang_users',
                Field('gang', db.gangs, required=True, notnull=True),
                Field('auth_user', db.auth_user, required=True,
notnull=True),
                Field('nickname', 'string', required=False, notnull=False),
                format = lambda r: "%s (%s)" % (r.auth_user.email,
r.nickname) if r.nickname else r.auth_user.email
)

When the "payer" field is shown in a SQLFORM, it will display a dropdown
with the list of users from the table gang_users, formatted according to
the "auth.user.email (nickname)" rule defined in the format parameter of
gang_users table.

However, I want to filter out this users, by doing in the controller:

db.expenses.payer.requires = IS_IN_DB(db(db.gang_users.gang == gang.id),
db.gang_users.nickname)

When the validator is set, only users from the given gang are displayed in
the dropdown, but I can display the nickname or id or any column from the
gang_users table. I would like to keep the "auth_users.email
(gang_users.nickname)" format as without the validator.

Is it possible?

Thanks very much.

-- 
(:=================================:)
 Alvaro J. Iradier Muro - [email protected]

-- 
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/d/optout.

Reply via email to