Improve the documentation of WidgetBase::errorElement() for mapping violation property paths to form elements

Created on 24 June 2013, over 11 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

Follow-up from #196972: How does hook_views_tabs() work? .

From #2614250-14: Number widget validation can break AJAX actions by amateescu:

\Drupal\Core\Field\WidgetBase::flagErrors(), line 423, $violation->getPropertyPath() returns an empty string, which means that $delta_element = $element; below will be $element[0]['value'] instead of just $element['value'], and that's why the call to $this->errorElement() below will send the wrong form array structure.

This probably causes the following major bugs:

Proposed resolution

Let's add the $sub_property_path of a validation violation to the errorElement() method of widgets, so they can be easily used when mapping them to elements. Probably, we can also default to 1:1 mapping between violated properties and elements.

Right, now those sub property path is already calculated and available via the undocumented $violation->arrayPropertyPath property.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs work

Version

10.1

Component
Field 

Last updated about 3 hours ago

Created by

🇦🇹Austria fago Vienna

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.71.5 2024