- Issue created by @marksmith
- First commit to issue fork.
- 🇮🇳India ushma
I have created an MR to fix the warning. Attached the patch for the same. Please review.
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).
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.
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'];
Patch file attached.
Active
2.2
Code
I have created an MR to fix the warning. Attached the patch for the same. Please review.