[web2py] IS_IN_SET validator
This example is given in the validators section of the book: requires = [IS_INT_IN_RANGE(0, 8), IS_IN_SET([2, 3, 5, 7], error_message='must be prime and less than 10')] It does not seem to work. If I attempt to combine IS_IN_SET with any other validator, the dropdown list doesn't work.
Re: [web2py] IS_IN_SET validator zero option
db.define_table('plan', Field('id','id'), Field('option',type='string',label=T('Subscription Options')), format='%(option)s', migrate=settings.migrate) db.define_table('subscription', Field('id','id'), Field('plan', db.plan, *required=True*), format='%(subscription)s', migrate=settings.migrate) *db.subscription.plan.requires = IS_IN_DB(db, 'plan.id' ,'%(option)s', zero=None)* -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] [ Aprenda a programar: http://CursoDePython.com.br ]
[web2py] IS_IN_SET validator zero option
Is there any way to use the IS_IN_SET validator zero option with a db field that is tied to a lookup table? For example, if I have db.define_table('plan', Field('id','id'), Field('option',type='string',label=T('Subscription Options')), format='%(option)s', migrate=settings.migrate) db.define_table('subscription', Field('id','id'), Field('plan', db.plan), format='%(subscription)s', migrate=settings.migrate) And then I use an SQL form on the subscription table, is there any way to validate the plan field is set using the built-in validators? Specifically, I'd like to use the IS_IN_SET validator with the zero option (great idea!!), but when I use it on the plan field above, the SQLFORM displays integer values instead of the value labels from the lookup table. If that's not possible, what would be the best way to make sure that this form option is set? Thank you! Eric
[web2py] IS_IN_SET validator not working as expected
i have the model db.define_table( 'foobar', Field('open', 'boolean', requires = IS_IN_SET([(True, 'open'), (False, 'closed')], zero = None), default = True, widget=SQLFORM.widgets.radio.widget), ) and the controller def edit(): return crud.update(db.foobar, request.args(0), deletable = False) but it does not work since open is always True because "False" gets interpreted as string with content and not as boolean so i have to fix it like this def edit(): def on_accept(form): open = False if request.vars.open == 'False' else True if form.vars.id and db.foobar[form.vars.id]: db.foobar[form.vars.id].update_record(open = open) return crud.update(db.foobar, onaccept = on_accept, request.args(0), deletable = False) are there alternatives to creating radioboxes for True False selections? Of course custom validator, but is there something already built in?
[web2py] IS_IN_SET validator
Hi , I have a database which contains a list:string field type and a requirement to be in a set of value ( with IS_IN_SET AND multiple=True ) . My question is how would you dynamically generate this set( my categories are stored in another table ) ? What i am trying to do is to allow user to select many categories ( yes this field is a category ) at the same time . IS-IN_DB does not work because it seems we cqn't select many choice. Do you use SQLFORM.factory , create the form manually or is there some special trick to pass this set Thx