Field states do not work on a "link" field

Created on 3 October 2023, about 1 year ago
Updated 14 March 2024, 9 months ago

Problem/Motivation

When a field of type 'link' is configured not to allow link text, then the defined state is not applied.

Steps to reproduce

1) Create a field of type "list" (text) with several values (Ex: none, test, lorem)
2) Create a "link" field and check the "disabled" radio button for the "Allow link text" part
3) In "Manage the display of a form", you must add a status on the "link" field (e.g.: invisible when the "list" field is set to "test")
4) Create content and change the value of the "list" field
5) If the value of the field "list" is "test" then the field "link" should be hidden but this is not the case

data-drupal-states attribute is not present in the HTML and an error is displayed :
Warning: Undefined array key "#type" in Drupal\Core\Form\FormHelper::processStates() (line 211 of core/lib/Drupal/Core/Form/FormHelper.php).

Proposed resolution

Simply add a container around the field so you can use the field states on it.

🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

🇫🇷France bakop Lille

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

Comments & Activities

Production build 0.71.5 2024