Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 303482

The field name is not displayed in LinkWidget error messages

$
0
0

Problem/Motivation

The LinkWidget validation callback error messages do not include the field name. If an entity form has multiple Link fields, then it may be difficult to tell which instance had the error.

Steps to reproduce

These steps will trigger one of the three validation callbacks, specifically the one for bad internal paths.

  1. Add two Link fields to any content type.
  2. Configure the Link fields to allow internal paths.
  3. Create a new instance of the content type. Add any garbage input like a random character string to the Link fields.
  4. Attempt to save the content.

Note that there is only one error message even though both fields triggered the error. The error message does not contain the name of either field. The user must search through the form to find the triggering fields.

Proposed resolution

The error messages in the LinkWidget validation callback functions should be updated to include the field name. The callbacks include:

  • validateUriElement()
  • validateTitleElement()
  • validateTitleNoLink()

You can use core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php as an example. That widget includes the field name in its validation callback. We will take that as a best practice.

Remaining tasks

  1. Write a new MR.
  2. Review.
  3. Commit.

User interface changes

Updated LinkWidget validation error messages.

Introduced terminology

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 303482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>