Hi,
it's not yet clear to me how to handle the check box correctly after the
change from 0.32 to 0.33. I assume the changes have been made in relation
to bug #128233. The following code used to work with 0.32, i.e. giving
"on" or None as result for the check boxes:
import web
template = '<form name="main" method="post">%s<input type="submit"/></form>'
urls = ('/', 'index')
app = web.application(urls, globals())
myform = web.form.Form(web.form.Checkbox('A', value=False),
web.form.Checkbox('B', value=True))
class index:
def GET(self):
form = myform()
return template % form.render()
def POST(self):
form = myform()
if not form.validates():
return template % form.render()
else:
return "Results: %s, %s" % (form['A'].value, form['B'].value)
if __name__=="__main__":
web.internalerror = web.debugerror
app.run()
With 0.33, this code leads immediately to an exception in web/form.py,
line 288. I replaced the value=True and value=False in "myform" with
checked=True and checked=False, but this gives always "None" as result,
never "on". While form['A'].checked gives the correct state, asking for
form['B'].checked gives always True, so this does not help neither.
Also, I would like to always use the same code for refering to a field
value, e.g. ".value", and not a different method only for check boxes.
What is the correct way of handling a check box now? What do I miss?
Thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.