I got this custom widget from the list:

def radio_h(field,value): 
    nbsp = XML(' ') 
    items=[TAG['']
(SPAN(name,INPUT(_type='radio',_value=key,_name=field.name,value=value)),nbsp,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