[web2py] Re: list:string type field is empty value on edit page
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: list:string type field is empty value on edit page
yeah, my mistake. thanks for correct me -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:string type field is empty value on edit page
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:string type field is empty value on edit page
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:string type field is empty value on edit page
No it is not. Something in the code must be resetting it. On Thursday, 4 April 2013 22:13:25 UTC-5, 黄祥 wrote: hi, is it normal for list:string type field is empty when on editing page? e.g. db.define_table('contact', *Field('salutation'),* Field('first_name'), Field('last_name'), *Field('gender', 'list:string'),* Field('birthday', 'date'), Field('job_title'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('fax'), Field('email'), *Field('account', 'reference account'),* format='%(first_name)s %(last_name)s') *db.contact.salutation.requires=IS_IN_SET(['Mr.', 'Mrs.', 'Ms.'])* db.contact.first_name.requires=IS_NOT_EMPTY() db.contact.last_name.requires=IS_NOT_EMPTY() *db.contact.gender.requires=IS_IN_SET(['Male', 'Female'])* db.contact.job_title.requires=IS_NOT_EMPTY() db.contact.address.requires=IS_NOT_EMPTY() db.contact.zip.requires=IS_MATCH('^\d{5,5}$', error_message='not a zip code') db.contact.city.requires=IS_NOT_EMPTY() db.contact.country.requires=IS_NOT_EMPTY() db.contact.phone.requires=IS_NOT_EMPTY() db.contact.email.requires=[IS_EMAIL(), IS_NOT_IN_DB(db, 'contact.email')] *db.contact.account.requires=IS_IN_DB(db, db.account.id, '%(account_name)s')* i make 3 different field type (bold) that contain drop down in the form view. why the value is always empty for the list:string type when i'm on the editing page? is it possible for not empty for list:string type in editing page? any idea or explaination about this? thank you so much before -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: list:string type field is empty value on edit page
is it related to the other field constructor, like required, label, etc? and for controller i'm using grid. *default.py* @auth.requires_login() def contact(): grid=SQLFORM.grid(db.contact, user_signature=False) return locals() *db_wizard.py* # create table : contact db.define_table('contact', Field('salutation'), Field('first_name'), Field('last_name'), Field('gender', 'list:string'), Field('birthday', 'date'), Field('job_title'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('fax'), Field('email'), Field('account', 'reference account'), format='%(first_name)s %(last_name)s') # create index : contact db.executesql('CREATE INDEX IF NOT EXISTS idx_contact ON contact (id, first_name, last_name);') # enable_record_versioning : contact db.contact._enable_record_versioning() *db_wizard_label.py* # contact db.contact.salutation.label=T('Salutation') db.contact.first_name.label=T('First Name') db.contact.last_name.label=T('Last Name') db.contact.gender.label=T('Gender') db.contact.birthday.label=T('Birthday') db.contact.job_title.label=T('Job Title') db.contact.address.label=T('Address') db.contact.zip.label=T('Zip') db.contact.city.label=T('City') db.contact.country.label=T('Country') db.contact.phone.label=T('Phone') db.contact.fax.label=T('Fax') db.contact.email.label=T('Email') db.contact.account.label=T('Account') *db_wizard_required.py* # contact db.contact.salutation.required=True db.contact.first_name.required=True db.contact.last_name.required=True db.contact.gender.required=True db.contact.job_title.required=True db.contact.address.required=True db.contact.zip.required=True db.contact.city.required=True db.contact.country.required=True db.contact.phone.required=True db.contact.email.required=True db.contact.account.required=True * db_wizard_requires.py* # contact db.contact.salutation.requires=IS_IN_SET(['Mr.', 'Mrs.', 'Ms.']) db.contact.first_name.requires=IS_NOT_EMPTY() db.contact.last_name.requires=IS_NOT_EMPTY() db.contact.gender.requires=IS_IN_SET(['Male', 'Female']) db.contact.job_title.requires=IS_NOT_EMPTY() db.contact.address.requires=IS_NOT_EMPTY() db.contact.zip.requires=IS_MATCH('^\d{5,5}$', error_message='not a zip code') db.contact.city.requires=IS_NOT_EMPTY() db.contact.country.requires=IS_NOT_EMPTY() db.contact.phone.requires=IS_NOT_EMPTY() db.contact.email.requires=[IS_EMAIL(), IS_NOT_IN_DB(db, 'contact.email')] db.contact.account.requires=IS_IN_DB(db, db.account.id, '%(account_name)s') On Friday, April 5, 2013 5:25:55 PM UTC-4, Massimo Di Pierro wrote: No it is not. Something in the code must be resetting it. On Thursday, 4 April 2013 22:13:25 UTC-5, 黄祥 wrote: hi, is it normal for list:string type field is empty when on editing page? e.g. db.define_table('contact', *Field('salutation'),* Field('first_name'), Field('last_name'), *Field('gender', 'list:string'),* Field('birthday', 'date'), Field('job_title'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('fax'), Field('email'), *Field('account', 'reference account'),* format='%(first_name)s %(last_name)s') *db.contact.salutation.requires=IS_IN_SET(['Mr.', 'Mrs.', 'Ms.'])* db.contact.first_name.requires=IS_NOT_EMPTY() db.contact.last_name.requires=IS_NOT_EMPTY() *db.contact.gender.requires=IS_IN_SET(['Male', 'Female'])* db.contact.job_title.requires=IS_NOT_EMPTY() db.contact.address.requires=IS_NOT_EMPTY() db.contact.zip.requires=IS_MATCH('^\d{5,5}$', error_message='not a zip code') db.contact.city.requires=IS_NOT_EMPTY() db.contact.country.requires=IS_NOT_EMPTY() db.contact.phone.requires=IS_NOT_EMPTY() db.contact.email.requires=[IS_EMAIL(), IS_NOT_IN_DB(db, 'contact.email')] *db.contact.account.requires=IS_IN_DB(db, db.account.id, '%(account_name)s')* i make 3 different field type (bold) that contain drop down in the form view. why the value is always empty for the list:string type when i'm on the editing page? is it possible for not empty for list:string type in editing page? any idea or explaination about this? thank you so much before -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.