Skip to content

SingleCheckboxWidget checked state not saved without value=selected #101

Description

@thet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions