Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boolean fields should be settable as required (or not) #5330

Closed
tkimnguyen opened this issue Oct 20, 2023 · 1 comment
Closed

boolean fields should be settable as required (or not) #5330

tkimnguyen opened this issue Oct 20, 2023 · 1 comment

Comments

@tkimnguyen
Copy link
Member

@davisagli was fixing this bug plone/plone.org#139 in plone.org with plone/plone.org#145 and we discussed how a customization to FormValidation.js was made for plone.org to allow requiring boolean fields.

Making this change in Volto would probably break some things so should be reserved for a major version upgrade.

This is a placeholder for discussion.

@davisagli
Copy link
Member

"required" for a boolean field means several different things in different places:

  1. In Zope schemas, a Bool field with required=True means that the field must be set to a boolean value (True or False) rather than None.
  2. In JSON-Schema (which the Zope schema gets serialized to in the REST API) in general, required is a list of property names that must be present in the object (whether or not they are set to a value).
  3. But volto makes a stronger interpretation of required in the JSON schema, and checks to make sure that the required properties are not empty.
  4. plone.org's customization goes a step further (too far IMO) and interprets a required boolean field as meaning that the value must be True.

I think volto's current implementation is good and matches the backend interpretation of required pretty well.

If plone.org needs to enforce that a boolean field is checked, it's probably better to do that with a validator instead of required=True. Then the customization wouldn't be needed.

@davisagli davisagli closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants