Nested IEF (complex form) stopped working for inner form

Created on 21 August 2024, 28 days ago
Updated 22 August 2024, 28 days ago

Problem/Motivation

Don't know what exactly broke this behaviour, it worked before for a long time. We're now on Drupal 10.3.2 and IEF 3.3.0-RC20, and we have an entity A which links to a different entity type B, which in itself links to a third entity type C.

For both nested references IEF complex forms, we allow to either create a new entity or select an existing one.

When we create a new entity type B (level 1) and within that, we want to select an existing entity type C (nested level 2), then IEF runs into an issue and throws the following exception:

Trying to access array offset on null in inline_entity_form_reference_form_submit() (line 187 of /var/www/html/web/modules/contrib/inline_entity_form/inline_entity_form.module)

#0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /var/www/html/web/modules/contrib/inline_entity_form/inline_entity_form.module(187): _drupal_error_handler()
#2 [internal function]: inline_entity_form_reference_form_submit()
#3 /var/www/html/web/modules/contrib/inline_entity_form/src/ElementSubmit.php(109): call_user_func_array()
#4 /var/www/html/web/modules/contrib/inline_entity_form/src/ElementSubmit.php(86): Drupal\inline_entity_form\ElementSubmit::doSubmit()
#5 [internal function]: Drupal\inline_entity_form\ElementSubmit::trigger()
#6 /var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array()
#7 /var/www/html/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#8 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#9 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#10 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#11 /var/www/html/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#12 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#13 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#14 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#16 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#17 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#22 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#23 /var/www/html/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#28 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#29 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#30 {main}

This is caused by $form_values = NestedArray::getValue($form_state->getValues(), $reference_form['#parents']); at line 185 of the module file which returns NULL because $form_state->getValues() doesn't contain form values but an array with just 1 element $array["ief-reference-submit-allocations-form-0-animal-form"]. The value is a TranslatableMarkup object.

This happens after selecting an existing entity in the autocomplete field and then clicking on Add @type_singular.

Doing the same for IEF entity references on the first level, this doesn't happen. Only for nested IEF reference forms.

Any idea what could be causing this?

🐛 Bug report
Status

Closed: works as designed

Version

3.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Comments & Activities

Production build 0.71.5 2024