Hello,

I have a simple form:

class ReportForm(TableForm):
    class fields(WidgetsList):
        passed = CheckBox(label_text='Passed Year')
        printRep = CheckBox(label_text='Print Report Card')
        id = HiddenField()

report_form = ReportForm("report_form",  action='reportsave',
submit_text="Update")

which is displaying OK on my template with:
${tmpl_context.form(report)}
where 'report' has attributes id, passed and printRep and the
CheckBoxes are getting set correctly depending on the data.

my 'reportsave' controller looks like this:
    @expose()
    def reportsave(self, **kw):
        reportData = DBSession.query(Report).filter(Report.id==kw
['id']).one()
        reportData.passed = kw['passed']
        reportData.printRep = kw['printRep']

If both the checkboxes are set initially, I can press the Submit
button and everything works fine.
kw is a dict with keys corresponding to the CheckBoxes and 'True' for
their values.

If however, one of the CheckBoxes is unset, I get a KeyError on that
CheckBox in the reportsave method after submitting.
The kw dict does not contain either the id of the CheckBox (e.g.
'passed') or its value (False?).
So, kw only contains the CheckBox identifier if the CheckBox is True/
Set.

Is the KeyError the intended way to know that the CheckBox is
unchecked?
Is this expected behaviour?

Thanks,

Jerry.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to