FormSetFieldError Action does not work for DropDown fields

Issue information

From user: danielspeicher

Related to !278 (merged)

Contribution record

Fork management

Problem/Motivation

I tagged this as a bug, even there is a workaround described below.

If the field is a drop-down, the error message does not appear.

Steps to reproduce

Just create a content type with a DropDrownList
Add an ECA model like the one attached.
Now try to create a content of this type.

I figured out:

For a required field, for example, Drupal Core passes the correct field name to setErrorByName in FormState.php.

Our Action Base class FormFieldValidateActionBase returns the wrapper field_grp_subitem_retirement_wrapper of that field here:

if ($target_element = &$this->getTargetElement()) {
     if (isset($target_element['#parents'])) {
       $form_state->setErrorByName(implode('][', $target_element['#parents']), $message);
       return;
     }
   }

For example, if the field name (DropDown field) is foo, this code passes foo_wrapper to the setErrorByName method.

Note: In my model, a changed the field name to foo_wrapper, then the code returns the correct field name, and it works. But I think, we must fix this, because it is not obvious for a user to add the word wrapper.

@mxh Maybe you have a good idea to fix this.

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information