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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to