You can put conditions into the field validator: Field('writer_user', 'string', requires=IS_IN_DB( db( (db.auth_user.id == db.auth_membership.user_id) & (db.auth_membership.group_id == db.auth_group.id) & (db.auth_group.role == 'your group here') ), db.auth_user.id )
On Friday, 12 January 2018 09:13:07 UTC, Oasis Agano wrote: > > Greetings, > > > I have defined a table referencing auth_user, but i want on the web form > select box to only bring users belonging to one group, > not showing all the system users. > > i am wondering if i should use a lambda function or if there is a way of > adding a condition on a reference field. > > E,g returning only users belonging in a writer group on the writer_user > > db.define_table('post', > Field('post_name','string', label="Name", > requires=IS_NOT_EMPTY()), > Field('description','text', label="Desc"), > Field('writer_user','reference auth_user', label="User"), > auth.signature, > format='%(post_name)s') > > Kr, > > Oasis > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.