Allow element-specific validators to remove required validation

Created on 21 February 2024, 7 months ago
Updated 12 March 2024, 6 months ago

Problem/Motivation

I am working on a complex field widget that sets #required on a certain property. This causes an error when using the "Remove" button on a multiple-value field if the property is empty (in this case, using #limit_validation_errors is not possible). I would like to be able to add a custom validator using #element_validate to remove the #required_but_empty property set during form validation and prevent errors from being set.

Otherwise, I would have to implement my own validation to ensure the field is not empty, add the required marker to the form label, add required properties to the element attributes, etc.

Steps to reproduce

Proposed resolution

During form validation, check for #required_but_empty to set errors.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Needs work

Version

11.0 🔥

Component
Form 

Last updated less than a minute ago

Created by

🇺🇸United States dabblela

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024