Quantcast
Viewing all articles
Browse latest Browse all 294303

hook_form_field_config_edit_form_alter receives field definition with wrong required value

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: #3460530: Required checkbox has the wrong value when using the default (Core) Required API plugin.

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.


Viewing all articles
Browse latest Browse all 294303

Trending Articles



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