hook_form_field_config_edit_form_alter receives field definition with wrong required value

Created on 26 July 2024, 3 months ago
Updated 1 August 2024, 3 months ago

Problem/Motivation

\Drupal\Core\Field\FieldItemList::defaultValueWidget() changes the required and description values of the field definition while rendering the default values form, but the problem is that these values aren't restored after rendering, which means that any code coming after this receives wrong description and required values when reading from the field definition. This was discovered in a contrib module reading the required value: πŸ› Required checkbox has the wrong value when using the default (Core) Required API plugin Needs review .

Steps to reproduce

Implement hook_form_field_config_edit_form_alter and read the required value. It will always be false.

Proposed resolution

Clone the field definition object before modifying.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 9 hours ago

Created by

πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024