You pass the validator to the field so that it passes it to the
widget. Your widget does not handle it. You can do:

def radio_h(field,value):
    nbsp = XML(' ')
    items=[TAG['']
(SPAN(name,INPUT(_type='radio',_value=key,_name=field.name,value=value,requires=IS_IN_DB(db,
db.gender, '%(description)s',
zero=None))),nb sp,nbsp)
        for key,name in field.requires.options()]
    return DIV(*items)

define_table('t',
Field('gender', 'reference gender',comment='*',widget=radio_h))



On Apr 10, 4:46 pm, niknok <nikolai...@gmail.com> wrote:
> Sorry for being a little thick but how do I do that? There's already a
> IS_IN_DB requires in the table definition.
>
> On Apr 11, 12:51 am, DenesL <denes1...@yahoo.ca> wrote:
>
>
>
>
>
>
>
> > You forgot to set the requires for t.gender
>
> > On Apr 9, 6:35 pm, niknok <nikolai...@gmail.com> wrote:
>
> > > I got this custom widget from the list:
>
> > > def radio_h(field,value):
> > >     nbsp = XML('&nbsp;')
> > >     items=[TAG['']
> > > (SPAN(name,INPUT(_type='radio',_value=key,_name=field.name,value=value)),nb
> > >  sp,nbsp)
> > >         for key,name in field.requires.options()]
> > >     return DIV(*items)
>
> > > In my controller:
> > > define_table('t',
> > > Field('gender', 'reference gender',comment='*',widget=radio_h))
> > > db.person.gender.requires=IS_IN_DB(db, db.gender, '%(description)s',
> > > zero=None)
>
> > > If I don't use the custom widget, the form will only validate if the
> > > user picks an answer for the gender field. If I use the custom widget,
> > > the form will validate even if there's no selected answer in the gender
> > > field. And then it will assign the first record in db.gender to the
> > > record, even if that wasn't selected at all.
>
> > > I think that assigning a default value in this case is not appropriate.
> > > So, how do I make this custom widget validate properly?
>
> > > /r
> > > Nik

Reply via email to