Thanks for your work around. I see this too. It seems more convenient to 
use:
    Field('gender','string',requires=IS_IN_SET(('Male', 'Female')))
as this will keep the default when in edit.


On Sunday, April 7, 2013 at 10:00:28 PM UTC-7, 黄祥 wrote:
>
> i've already start testing using the simple table (start from scratch) but 
> got the same result. here is my conclusion, please correct me if i'm wrong :
> - if you combine list:string field with IS_IN_SET validator, in form edit 
> you will receive blank value in drop down, not the existing value that 
> stored in database. 
> - if you want to use IS_IN_SET validator and in form edit will show the 
> existing value that store in database, please use string type field in your 
> define table.
>
> *e.g. in form edit receive blank value in drop down field, not the 
> existing value that stored in database*
> *db.py*
> db.define_table('gender',
>     Field('gender', 'list:string'),
>     format='%(gender)s')
>
> db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])
>
> *default.py*
> def gender():
>     grid=SQLFORM.grid(db.gender, user_signature=False)
>     return locals()
>
> *default/gender.html*
> {{extend 'layout.html'}}
>
> {{=grid}}
>
> *e.g. in form edit will show the existing value that store in database*
> *db.py*
> db.define_table('gender',
>     Field('gender'),
>     format='%(gender)s')
>
> db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])
>
> *default.py*
> def gender():
>     grid=SQLFORM.grid(db.gender, user_signature=False)
>     return locals()
>
> *default/gender.html*
> {{extend 'layout.html'}}
>
> {{=grid}}
>

-- 
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