Datetime field name missing from validation error message

Created on 17 April 2023, over 1 year ago
Updated 18 May 2023, over 1 year ago

Problem/Motivation

A datetime field when configured with the Date and Time widget, is missing the field's name in the validation error message when it fails validation. The problem is caused by the way the widget is rendered; it omits setting the $element['#title'] as the latter is rendered as part of a parent fieldset instead. Whilst there is nothing wrong with this, the Datetime validation logic uses the $element['#title']'s value to determine the field name.

Steps to reproduce

  1. Add a datetime field to a content type
  2. Set the datetime field as required
  3. Set the datetime field's form display to use the Date and Time field widget in Form display
  4. Create a new node of the content type and save the form without filling the datetime field
  5. Observe that the validation error message produced is missing the datetime field name

Proposed resolution

Align the $title parsing logic in the Datetime.php class with the one from the Datelist.php class which has fallback logic on the element's parent.

Remaining tasks

n/a

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component
Datetime 

Last updated 2 days ago

Created by

🇲🇺Mauritius pascalim

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024