You cannot this way. The form (and the list of options) is generated before
the user selects the user_id therefore you cannot generate the second list
before you know which of the first options is selected.
You need a two steps form. first you ask the user. then you filter all the
groups for that user.
On Saturday, 6 August 2016 02:00:00 UTC-5, stickman wrote:
>
> Hi all,
>
> I am having trouble creating a query for a dropdown list.
>
> Scenario,
>
> I have auth_user 'bill', who has auth_membership 'user1' and 'user2'
> If I wanted 'bill' to have another auth_membership, I would like to have a
> dropdown showing all the memberships availabe, except the ones he already
> has.
> ex. show only 'user3' and 'user4'.
>
>
> I am using SQLFORM.factory for my form
>
> form = SQLFORM.factory(Field('user_id', requires=IS_IN_DB(db(
> db.auth_user.id == id), 'auth_user.id', '%(username)s',zero=None)),
> Field('group_id',requires=IS_IN_DB(db(
> db.auth_user.id == id),'auth_group.id','%(role)s')),
> submit_button='Add New Membership')
>
> This is my first post on this forum, I hope I am clear with my question.
> Thanks in advance
>
>
--
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.