Undefined array key "form_display"

Created on 1 August 2025, 2 months ago

Problem/Motivation

In Drupal 11.2, I use the ief_popup (and inline_entity_form) inside an entity_browser modal frame (to create new content via ief). When I open an inline entity form within an entity browser modal window, I receive this error message: Warning: Undefined array key "form_display" in ief_popup_inline_entity_form_entity_form_alter() (line 143 of modules/contrib/ief_popup/ief_popup.module).

Steps to reproduce

1. Create a reference field having Entity browser as a form widget with view as well as create (entity_form) widgets.
2. The entities to be created contain further entity reference fields having inline_entity_forms with ief_popup as form widgets. This entity will pupup inside the entity browser window during the create operation.
3. Once you open the ief_popup inside the entity browse modal, the above error is shown.

Proposed resolution

This error indicates that the ief_popup module is trying to access a form_display array key that doesn't exist when combining inline entity forms with entity browser.

The problematic line is this code:

$form_display = $form_state->getStorage()['form_display'];

The following rewrite solved the problem in my case (note that this is the 2.2.x-dev version):

  // Check if form_display exists in storage before accessing it
  $storage = $form_state->getStorage();
  if (!isset($storage['form_display'])) {
    return; // Exit early if form_display is not available
  }
  
  /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $form_display */
  $form_display = $storage['form_display'];

Remaining tasks

Patch file attached.

🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

🇮🇪Ireland marksmith

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024