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.

Command icon 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

klaasvw created an issue. See original summary.

klaasvw’s picture

Status: Active » Needs review
StatusFileSize
new559 bytes

The attached patch wraps the return value in a markup render array element.

silvi.addweb made their first commit to this issue’s fork.

silvi.addweb’s picture

Status: Needs review » Reviewed & tested by the community

I have tested and it's working as expected. I also raised MR for the same.

Berdir made their first commit to this issue’s fork.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Both calls for this method seem to have check that converts strings, but makes sense to unify this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.