Overview of features
Home
Read this first
About
web2py is 100% free
Download
Start learning web2py today
Documentation
Authors and contributors
Staff
Affiliated companies
Support
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
The documentation shows a usage example like: ` FORM(SELECT('option1', 'option2', 'option3',_name="my_selector"))` ---- SELECT using values from a list ---- however, when we create an option box dynamically, we will probably have a list of options. in this case, we will use SELECT as follows: ` options = ['option1', 'option2', 'option3'] FORM(SELECT(*options, **dict(_name="my_selector"))` ---- SELECT using values from a database table ---- When we want the user to select values from a database (eg names), but we want the form to return the associated primary key, we can do as follows: ` staff = db(db.staff.ALL).select() FORM(TR("Select a user :", SELECT(_name='staffselect', *[OPTION(staff[i].username, _value=str(staff[i].id)) for i in range(len(staff))])), TR(INPUT(_type='submit')))` Now the option box will display the usernames, but the form will return the staff.id