- Issue created by @jasdeba
When using an inline entity form on an entity that has revisions enabled (In my case because of content moderation), the entire edit-form breaks when the referenced entity in the IEF does not support revisions.
This is caused by invoking hook_entity_prepare_form. The (non-revisioned) referenced entity is passed, together with the form_state of the main (revisioned) entity.
LogicException: Entity type event does not support revisions. in Drupal\Core\Entity\ContentEntityBase->setNewRevision() (line 293 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityStorageBase->createRevision(Object, ) (Line: 310)
Drupal\content_moderation\EntityTypeInfo->entityPrepareForm(Object, 'add', Object) (Line: 156)
content_moderation_entity_prepare_form(Object, 'add', Object) (Line: 276)
Drupal\inline_entity_form\Form\EntityInlineForm->Drupal\inline_entity_form\Form\{closure}(Object, 'content_moderation') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_prepare_form', Object) (Line: 277)
Drupal\inline_entity_form\Form\EntityInlineForm->prepareInvokeAll(Object, 'entity_prepare_form', Object) (Line: 187)
Drupal\inline_entity_form\Form\EntityInlineForm->entityForm(Array, Object) (Line: 152)
Drupal\inline_entity_form\Element\InlineEntityForm::processEntityForm(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 1012)
Drupal\Core\Form\FormBuilder->doBuildForm('node_event_edit_form', Array, Object) (Line: 1075)
Drupal\Core\Form\FormBuilder->doBuildForm('node_event_edit_form', Array, Object) (Line: 1075)
Drupal\Core\Form\FormBuilder->doBuildForm('node_event_edit_form', Array, Object) (Line: 1075)
Drupal\Core\Form\FormBuilder->doBuildForm('node_event_edit_form', Array, Object) (Line: 1075)
Drupal\Core\Form\FormBuilder->doBuildForm('node_event_edit_form', Array, Object) (Line: 579)
Drupal\Core\Form\FormBuilder->processForm('node_event_edit_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 583)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 166)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
For now, I reverted the fix introduced in https://www.drupal.org/project/inline_entity_form/issues/3015323 🐛 IEF does not invoke hook_entity_prepare_form Fixed
Active
2.0
Code