thanks. In trunk.

On Jan 29, 6:28 pm, Bernd Rothert <roth...@googlemail.com> wrote:
> There is a small bug in web2py's HTML checkbox helper:
>
> >>> from gluon.html import *
> >>> print INPUT(_type='radio', _value=2, value='2'])
>
> <input checked="checked" type="radio" value="2" />
>
> >>> print INPUT(_type='checkbox', _value=2, value=['1', '2', '3'])
>
> <input type="checkbox" value="2" />
>
> >>> print INPUT(_type='checkbox', _value='2', value=['1', '2', '3'])
>
> <input checked="checked" type="checkbox" value="2" />
>
> It's just a missing str() in the checkbox helper:
>
> diff -r b3585c174233 gluon/html.py
> --- a/gluon/html.py Sat Jan 29 09:53:43 2011 -0600
> +++ b/gluon/html.py Sun Jan 30 01:00:39 2011 +0100
> @@ -1502,7 +1502,7 @@
>          if not t:
>              t = self['_type'] = 'text'
>          t = t.lower()
> -        value, _value = self['value'], self['_value']
> +        value, _value = self['value'], str(self['_value'])
>          if t == 'checkbox':
>              if not _value:
>
> Maybe a test similar to this one could be added to gluon/tests/test_html.py:
>
> assert str(INPUT(_type='checkbox', _value=2, value=['1', '2', '3'])) \
>     == str(INPUT(_type='checkbox', _value='2', value=['1', '2', '3']))
>
> Background: The web2py book suggests that the default
> "SQLFORM.widgets.multiple.widget" can be replaced with
> "SQLFORM.widgets.checkboxes.widget" for list:reference fields. I tried it
> but the checkboxes did not show any check marks because of the int/string
> mismatch.
>
> Cheers
> Bernd

Reply via email to