zopefoundation / z3c.form

An advanced form and widget framework for Zope 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SingleCheckboxWidget checked state not saved without ``value=selected``

thet opened this issue · comments

What I did:

I had a field which uses a z3c.form SingleCheckboxWidget. Field definition:

    some_bool = zope.schema.Bool(
        title="some title",
        required=False,
        default=False,
    )

And this was the manually set HTML code for the checkbox:

    <input name="some_bool" type="checkbox" />

What I expect to happen:

Saving the form with a checked checkbox should have resulted in a set boolean for the object.

What actually happened:

The boolean was not set because:

    <input name="some_bool" type="checkbox" value="selected" />

I'd have expected that a <input name="some_bool" type="checkbox"/> as a prototypical representation of booleans in html forms to just work out of the box.

I suggest to also add the term on to

vocabulary.SimpleTerm('selected', 'selected',

Not sure, but I guess that would solve the issue...

What version of Python and Zope/Addons I am using:

  • Ubuntu 20.04.1
  • Python 3.8.5
  • z3c.form-3.7.1-py3.8.egg
  • Zope-4.5.5-py3.8.egg
  • Products.CMFPlone-5.2.4-py3.8.egg

@thet Did Dieter's explanation solve your problem, so the issue can be closed?