Use the "value" argument instead of _checked: _input = INPUT(_type='checkbox', _name=field.name, _class='checkbox', value='on' if request.post_vars[field.name] != None else '')
Anthony On Monday, December 14, 2015 at 12:33:39 AM UTC-5, Alfonso Serra wrote: > > Hey i was creating a custom widget for a checkbox and i wanted to keep the > value when the form doesnt validate. > > This is the declaration for the input: > > chk = request.post_vars[field.name] != None > > if chk: > _input = INPUT(_type="checkbox", _name=field.name, _class="checkbox", > _checked="on") > else: > _input = INPUT(_type="checkbox", _name=field.name, _class="checkbox") > return _input > > The resulting html after a postback is: > <input class="checkbox" name="confirm" value="on" type="checkbox"> > > The property "checked" is mapped to the "value" property, and the checkbox > is not checked in return. > This test was on Firefox v.42 > > Ive tried to workaround this behaviour but im not able to fix this. > > After a postback the property cheked is poped out of the input. > > -- 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.