checkbox form validation link goes to non-existent id

Created on 19 November 2023, 10 months ago

Problem/Motivation

If I create a custom validator for a checkbox field and I try to set the error path to that field, a fragment link gets generated to the field, but it does not work because the id does not exist.

Steps to reproduce

Example:
Create a field 'field_show_banner';
Create validator for the entity and specify the error path to the field

// Multiple errors should go on the checkbox.
$field_error_path = 'field_show_banner';

There validator works and creates a message that says " 1 error has been found: Display a banner alert on this facility"
but with a link around the title of the field. But the link is incorrect. It looks like
<a href="#edit-field-show-banner">Display a banner alert on this facility</a>

The problem is there is no id of `edit-field-show-banner` so the link does not serve its function to jump to the error.
The closest ids are
edit-field-show-banner-value
edit-field-show-banner-wrapper

Setting the path by hand can not be set to include value or wrapper because then no link gets rendered
$field_error_path = 'field_show_banner'; // Results in link with non-existent id.
$field_error_path = 'field_show_banner-value'; // No link generated.
$field_error_path = 'field_show_banner_value'; // No link generated

Proposed resolution

Either
Add the field id to the output field or make the error link point the field-name-value.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
FormΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

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

Comments & Activities

Production build 0.71.5 2024