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

  1. Install Require on Publish.
  2. Create a boolean field on a content type.
  3. Configure the field to use the single checkbox widget.
  4. Enable Required on Publish for the field.
  5. Create content and publish it without checking the checkbox.
  6. 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/TRUE satisfies Required on Publish.
  • For radio/options widgets, an explicit FALSE value 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.
Command icon 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

jcandan created an issue. See original summary.

jcandan’s picture

jcandan’s picture

Assigned: jcandan » Unassigned
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • jcandan committed 24914277 on 2.1.x
    fix: #3590184 Fix boolean field single checkbox validation while...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.