Hi,

I've been trying to add a radio button set to one of my web forms. I'm
generating the form with SQLFORM.factory, because I'm adding a non db field
to it.

Example model:

db.define_table('mytable',
    Field('name', 'string', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, '
mytable.name')]),
    # some fields omitted
    Field('radiofield', 'boolean', widget=SQLFORM.widgets.radio.widget,
requires=IS_IN_SET({True : 'On', False : 'Off', None : 'Neither'})))

In the controller:

def new():
    form = SQLFORM.factory(db.mytable, Field('specialfield', 'string'),
labels={'specialfield' : 'Special Field'})
    if form.accepts(request.vars, session):
        # do some handling of special field, then a manual db insert, here
omitted
        return dict(form=form, radio=form.vars.radiofield) # when not
debugging this is a redirect to another controller
    return dict(form=form)

The form shows with three radio buttons: On, Off and Neither. But no matter
which one I choose, form.vars.radiofield is always True after calling
form.accepts.

Examining request.vars.radiofield variable, the correct chosen value is
shown there.

Am I doing something wrong here, or is it a bug?

// Jens

Reply via email to