Problem/Motivation
When using the entity label option for displaying the selected entities in the field widget, the following error is displayed:
User error: "display" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php)
The \Drupal\entity_browser\Plugin\EntityBrowser\FieldWidgetDisplayEntityLabel::view method expects to return a render array. Instead, if the entity has a label, it returns the EntityInterface::label method value, which has one of the string|\Drupal\Core\StringTranslation\TranslatableMarkup|null types.
Steps to reproduce
- Select entity browser as field widget when configuring the form display
- When configuring the field widget select "Entity label" as Entity display plugin
- Edit an entity that uses the widget
Proposed resolution
This can be fixed by wrapping the returned string into a render array markup element.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | entity-browser-entity-label-field-widet-3418337-2.patch | 559 bytes | klaasvw |
Issue fork entity_browser-3418337
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
klaasvw commentedThe attached patch wraps the return value in a markup render array element.
Comment #5
silvi.addweb commentedI have tested and it's working as expected. I also raised MR for the same.
Comment #7
berdirBoth calls for this method seem to have check that converts strings, but makes sense to unify this.