Mandatory checkboxes in Plone 6

We updated our website to Plone 6 (6.0.7 exactly) and we noticed a bug, that I thing has been reported, but I can not manage to find:

A checkbox now is mandatory (you have to check it) despite that on the interface for that content type is marked as default=False.

My search skills are not so good, so, can anyone point me to the right direction, or tell me if on Plone 6.0.10.1 (latest release) is already fixed? :four_leaf_clover:

I remember this: IField.required attribute is True but must not. ยท Issue #104 ยท zopefoundation/zope.schema ยท GitHub
with many pointers to the issue.

gforcada via Plone Community wrote at 2024-3-7 15:25 +0000:

...
A checkbox now is mandatory (you have to check it) despite that on the interface for that content type is marked as default=False.

This is a bug in the browser UI interface for boolean fields.

For a boolean field, you must in principle provide a representation
for three values: "True", "False"" and "not specified".
A checkbox, however can represent only the 2 values
"checked" and "not checked".
A "not checked" checkbox can mean either "False" or "not specified".
The behavior you observe menas that "not specified" is the prefered meaning.

You have different options:

  • use a different widget (instead of a checkbox widget) able to prepresent
    3 values
  • ensure that the checkbox's "not checked" is mapped to False
    rather than "not specified".

Plone is likely still based on "z3c.form"; read its documentation
how to control via adapters which widgets are used for fields
and how a widget value is mapped to a field value.

Thanks! :smile:

For a seemingly simple problem, how complicated things can turn :face_with_spiral_eyes:

For mere mortals fortunately it boils down to add a required=False to your zope.schema.Bool fields :tada:

2 Likes