Maybe your patch is ok. But wouldn't it be not necessary to use
requires=[IS_IN_SET(...), IS_NOT_EMPTY()]? Because you must already
mention all the allowed values in the IS_IN_SET() and usually empty
value in not inside.

On Jun4, 1:36am, Mathieu Clabaut <mathieu.clab...@gmail.com> wrote:
> Hello,
>
> Is there any interest in this problem ? Is there any chance a correction may
> be integrated into trunk ?
>
> -Mathieu
>
> On Thu, May 27, 2010 at 20:20, Mathieu Clabaut <mathieu.clab...@gmail.com>
>
>
>
>
>
>  wrote:
> > Reported ashttp://code.google.com/p/web2py/issues/detail?id=80
>
> > Hello,
>
> > I've met a problem with checkboxes and rzdio widgets:
>
> > The following works:
> > Field('status', 'string', requires=IS_IN_SET(STATUS_TYPE, multiple=True),
> >         widget=SQLFORM.widgets.checkboxes.widget)
>
> > However if I add another validator, it doesn't work anymore :
> > Field('status', 'string', requires=[IS_IN_SET(STATUS_TYPE, multiple=True),
> > IS_NOT_EMPTY()],
> >         widget=SQLFORM.widgets.checkboxes.widget)
>
> > Any suggestion ?
>
> > -Mathieu
>
> On Thu, May 27, 2010 at 20:38, Mathieu Clabaut 
> <mathieu.clab...@gmail.com>wrote:
>
>
>
> > Patch :
>
> > diff -r 9802a87428fa gluon/sqlhtml.py
> > --- a/gluon/sqlhtml.py Wed May 26 17:17:46 2010 +0200
> > +++ b/gluon/sqlhtml.py Thu May 27 20:37:56 2010 +0200
> > @@ -223,10 +223,15 @@
>
> >          attr = OptionsWidget._attributes(field, {}, **attributes)
>
> > -        if hasattr(field.requires, 'options'):
> > -            options = field.requires.options()
> > -        else:
> > -            raise SyntaxError, 'widget cannot determine options of %s' %
> > field
> > +        requires = field.requires
> > +        if not isinstance(requires, (list, tuple)):
> > +            requires = [requires]
> > +        if requires:
> > +            if hasattr(requires[0], 'options'):
> > +                options = requires[0].options()
> > +            else:
> > +                raise SyntaxError, 'widget cannot determine options of %s'
> > \
> > +                    % field
> >          opts = [TR(INPUT(_type='radio', _name=field.name,
> >                           requires=attr.get('requires',None),
> >                           hideerror=True, _value=k,
> > @@ -250,10 +255,15 @@
>
> >          attr = OptionsWidget._attributes(field, {}, **attributes)
>
> > -        if hasattr(field.requires, 'options'):
> > -            options = field.requires.options()
> > -        else:
> > -            raise SyntaxError, 'widget cannot determine options of %s' %
> > field
> > +        requires = field.requires
> > +        if not isinstance(requires, (list, tuple)):
> > +            requires = [requires]
> > +        if requires:
> > +            if hasattr(requires[0], 'options'):
> > +                options = requires[0].options()
> > +            else:
> > +                raise SyntaxError, 'widget cannot determine options of %s'
> > \
> > +                    % field
>
> >          options = [(k, v) for k, v in options if k!='']
> >          opts = []

Reply via email to