Entity label EntityBrowserFieldWidgetDisplay plugin should return a render array

Created on 31 January 2024, 5 months ago
Updated 17 May 2024, about 1 month ago

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.

๐Ÿ› Bug report
Status

RTBC

Version

2.10

Component

Widget plugins

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium klaasvw

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024