Problem/Motivation
A boolean field marked Required on Publish can be published while unchecked when it uses the single checkbox widget.
This differs from Drupal core's normal required single-checkbox behavior, where an unchecked required boolean checkbox does not pass form validation.
For that widget, unchecked should mean the required-on-publish requirement has not been satisfied.
However, this should not make all boolean FALSE values invalid. When a boolean field uses radio/options-style widgets, an explicit "No" selection is a valid answer. In that case, 0/FALSE should continue to satisfy Required on Publish.
Steps to reproduce
- Install Require on Publish.
- Create a boolean field on a content type.
- Configure the field to use the single checkbox widget.
- Enable Required on Publish for the field.
- Create content and publish it without checking the checkbox.
- Observe that the content can be published without a validation error.
Expected result
A required-on-publish boolean field using the single checkbox widget should fail validation when unchecked during publish.
Actual result
The unchecked value is treated as a valid field value and publish validation does not fail.
Proposed resolution
Make ROP boolean validation widget-aware:
- For
boolean_checkbox, only checked/TRUEsatisfies Required on Publish. - For radio/options widgets, an explicit
FALSEvalue remains valid. - For other field types, continue using the existing emptiness behavior.
Add test coverage for both cases:
- Required-on-publish boolean single checkbox unchecked is invalid on publish.
- Required-on-publish boolean radio/options value "No" is valid on publish.
Issue fork require_on_publish-3590184
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jcandan commentedComment #4
jcandan commented