stumble upon this post.  For some reason, this don't work:

*model:*

db.define_table('mytable',
                Field('name', type='list:string',requires=IS_IN_SET 
(['red', 'blue','yellow']),widget=lambda field, value: 
SQLFORM.widgets.checkboxes.widget(field, value, 
_style='bootstrap3_inline_factory', label=True)),
                Field("roles", "text")

*default:*
db.mytable.roles.show_if = (db.mytable.name.belongs(['red']))

or even:

db.mytable.roles.show_if = (db.mytable.name =='red')



On Tuesday, June 16, 2015 at 7:52:30 AM UTC-4, kecajk...@gmail.com wrote:
>
> Works! Thanks. 
> Is it also possible for SQLFORM.factory? 
>
> On Wednesday, 10 June 2015 16:06:47 UTC+2, Anthony wrote:
>>
>> Try:
>>
>> db.table1.order.show_if = db.table1.colour.belongs(['red', 'blue'])
>>
>> Anthony
>>
>> On Tuesday, June 2, 2015 at 6:09:20 AM UTC-4, kecajk...@gmail.com wrote:
>>>
>>> Hi, 
>>>
>>> I'm using show_if to hide a filed of my form under certain conditions.
>>> Per web2py guide, show_if uses simple query, but it doesn't work for 
>>> logical oprators like "and" "or".
>>> In below example i would like to display field "order" just when colour 
>>> is set to "blue" or "red".
>>>
>>> db.define_table('table1', Field('colour', 
>>> requires=IS_IN_SET(['blue','red','yellow'])), Field('order'))
>>>
>>> ## That works fine
>>> db.table1.order.show_if = (db.table1.colour=='red')
>>>
>>> #that doesn't work returning error " 'Query' object has no attribute 
>>> 'tablename'"
>>> db.table1.order.show_if = (db.table1.colour=='red') | 
>>> (db.table1.colour=='blue')
>>>
>>> form=SQLFORM(db.table1)
>>>
>>>
>>> Any ideas?
>>>
>>> Also is it possible to use show_if with SQLFORM.factory ? I don't need 
>>> database for that form, but i want to use show_if.
>>>
>>> Thanks.
>>>
>>

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

Reply via email to