db.define_table('gender',
    Field('gender', 'list:string'),
    format='%(gender)s')

db.gender.gender.requires=IS_IN_SET(['Male', 'Female'])

should be

db.define_table('gender',
    Field('gender', 'list:string'),
    format='%(gender)s')
db.gender.gender.requires=IS_IN_SET(['Male', 'Female'],mutliple=True)

if you have a list of strings, you must allows multiple options. It does 
not make much sense in the Male/Female case (or perhaps it does, not sure).

On Monday, 8 April 2013 00:00:28 UTC-5, 黄祥 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}}
>

-- 

--- 
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/groups/opt_out.


Reply via email to