A workaround: enclose the value in quotes.

e.g.  db.news.link.show_if = (db.news.category=='1')

As a plus, I believe it will keep on working even after running a version 
of web2py that has the fix.



On Saturday, November 8, 2014 3:26:30 PM UTC-5, Niphlod wrote:
>
>
> https://github.com/web2py/web2py/commit/1e35262e6746dd74485587ddef25205573785ca9
>
> 2.9.11 still doesn't include the fix
>
> On Saturday, November 8, 2014 4:44:54 PM UTC+1, DenesL wrote:
>>
>> May I ask in which release is it fixed?.
>> Just re-downloaded 2.9.11 and it has the exact same problem as 2.9.5
>>
>> Any request for help should including as much info as required to 
>> reproduce it, the easier one makes it for others to test the more likely 
>> you will get the help you need.
>>
>> Denes
>>
>>
>> On Saturday, November 8, 2014 7:15:01 AM UTC-5, Niphlod wrote:
>>>
>>> already fixed. 
>>> For the future:
>>> - avoid reporting bugs without examples
>>> - check if the bug is still in the latest version (2.9.5 is 8 months 
>>> ago!)
>>>
>>> :-P
>>>
>>> On Saturday, November 8, 2014 12:59:50 AM UTC+1, DenesL wrote:
>>>>
>>>> Sure:
>>>>
>>>> # news.py model:
>>>> db.define_table('news',
>>>>   Field('category','integer'),
>>>>   Field('title'),
>>>>   Field('link'),
>>>>   Field('comments'),
>>>>   Field('votes','integer'),
>>>>   )
>>>>
>>>> # action
>>>> def news_create():
>>>>     db.news.link.show_if = (db.news.category==1)
>>>>     db.news.votes.default = 0
>>>>     form = SQLFORM(db.news)
>>>>     return locals()
>>>>
>>>> # view
>>>> {{extend 'layout.html'}}
>>>> <h2>New Item</h2>
>>>> {{=form}}
>>>>
>>>> It will work with
>>>>   db.news.link.show_if = (db.news.category==2)
>>>> or any value except 1 or 0, even negatives.
>>>> If the value is 0 it will not even hide the row.
>>>>
>>>> FYI using web2py 2.9.5
>>>>
>>>> Denes
>>>>
>>>> On Friday, November 7, 2014 6:41:40 PM UTC-5, Niphlod wrote:
>>>>>
>>>>> care to show an example ?
>>>>>
>>>>> db.define_table('purchase', Field('have_coupon','integer', default=1),
>>>>> Field('coupon_code'))
>>>>>
>>>>>
>>>>> def index():
>>>>>     db.purchase.coupon_code.show_if = (db.purchase.have_coupon==1)
>>>>>     form = SQLFORM(db.purchase).process()
>>>>>     return dict(form = form)
>>>>>
>>>>>
>>>>> works totally fine.
>>>>>
>>>>> On Friday, November 7, 2014 11:23:52 PM UTC+1, DenesL wrote:
>>>>>>
>>>>>> While reviewing another post ( 
>>>>>> https://groups.google.com/forum/#!topic/web2py/1UOl694VtIs )
>>>>>> I noticed that the code generated for the show_if does not work when 
>>>>>> the field is integer and the value is 1
>>>>>> since the data-show-if attribute is set to ":checked" and not 
>>>>>> "[value='1']" as it should be.
>>>>>>
>>>>>> It is probably something in the show_if function of gluon/sqlhtml.py 
>>>>>> relating to the truthness of the value 1.
>>>>>>
>>>>>> One for the bug hunters.
>>>>>>
>>>>>> Denes 
>>>>>>
>>>>>

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