Use standard required error message

Created on 14 April 2025, 5 days ago

Problem/Motivation

I want the required error message from the Conditional Fields module to be consistent with the rest of the framework.

This module can conditionally set a field as required. This is not validated in the browser via an HTML attribute but also in the backend.

Currently the required error message is '%name is required.' introduced in #2833368: Fix conditionally required fields message and label . The relevant code is src/ConditionalFieldsFormHelper.php:623.

Drupal core uses '@name field is required.' as default required error message. This can be seen in core/lib/Drupal/Core/Form/FormValidator.php:299.

The message from Drupal core is also used at multiple places.

Steps to reproduce

  1. Configure an node type with
    • required field field_dependee.
    • optional field field_dependent.
  2. Configure a field condition so that field_dependent becomes required when field_dependee has no value.
  3. Open the creation form page for the node type.
  4. Disable frontend form validation (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form#novalidate).
  5. Submit the form without filling any field.
  6. Expect the required error message for field_dependee and field_dependent to be identical

Proposed resolution

Use the Drupal required error message.

Remaining tasks

  • Implement test.
  • Implement solution.
  • Review

User interface changes

The required error messages are consistent.

API changes

None.

Data model changes

None.

Feature request
Status

Active

Version

4.0

Component

Code

Created by

🇩🇪Germany tgauges

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024