AlterEgo
old web2py blog
Useful Links
List all entries
Book
Interactive Examples
F.A.Q.
Free Applications
Plugins
Recipes
Demo of Admin Interface
Semantic web extension
Some of the information here may be outdated, please check the book instead
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
© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by
web2py
- design derived from a theme by
the earlybird
The content of this book is released under the
Artistic License 2.0
- Modified content cannot be reproduced.