Editing an existing ECK entity inline causes AJAX error

Created on 3 August 2023, over 1 year ago
Updated 31 August 2023, about 1 year ago

Problem/Motivation

When adding an existing ECK entity to an Inline entity form - Complex field and then trying to edit that entity, you receive an AJAX error. Adding and then editing a brand new ECK entity created inline works. Removing a new or existing ECK entity works. Referencing a non-ECK entity also works.

The issue is editing an existing ECK entity inline. This issue does not occur in version 2.0.0-rc6. It seems to have been added in 2.0.0-rc7.

AJAX error

Uncaught Drupal.AjaxError {message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 50…Drupal\\Core\\DrupalKernel->handle() (Line: 19)\n', name: 'AjaxError'}message: "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 500\nDebugging information follows.\nPath: /node/add/article?ajax_form=1&_wrapper_format=drupal_ajax\nStatusText: error\nResponseText: The website encountered an unexpected error. Please try again later.LogicException: Entity type external_contact 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() (Line: 310)\nDrupal\\content_moderation\\EntityTypeInfo->entityPrepareForm() (Line: 158)\ncontent_moderation_entity_prepare_form() (Line: 276)\nDrupal\\inline_entity_form\\Form\\EntityInlineForm->Drupal\\inline_entity_form\\Form\\{closure}() (Line: 405)\nDrupal\\Core\\Extension\\ModuleHandler->invokeAllWith() (Line: 277)\nDrupal\\inline_entity_form\\Form\\EntityInlineForm->prepareInvokeAll() (Line: 187)\nDrupal\\inline_entity_form\\Form\\EntityInlineForm->entityForm() (Line: 152)\nDrupal\\inline_entity_form\\Element\\InlineEntityForm::processEntityForm()\ncall_user_func_array() (Line: 1012)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 1075)\nDrupal\\Core\\Form\\FormBuilder->doBuildForm() (Line: 154)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->doBuildForm() (Line: 449)\nDrupal\\Core\\Form\\FormBuilder->rebuildForm() (Line: 162)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->rebuildForm() (Line: 633)\nDrupal\\Core\\Form\\FormBuilder->processForm() (Line: 144)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->processForm() (Line: 325)\nDrupal\\Core\\Form\\FormBuilder->buildForm() (Line: 97)\nDrupal\\autosave_form\\Form\\AutosaveFormBuilder->buildForm() (Line: 73)\nDrupal\\Core\\Controller\\FormController->getContentResult() (Line: 39)\nDrupal\\layout_builder\\Controller\\LayoutBuilderHtmlEntityFormController->getContentResult()\ncall_user_func_array() (Line: 123)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 580)\nDrupal\\Core\\Render\\Renderer->executeInRenderContext() (Line: 124)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 169)\nSymfony\\Component\\HttpKernel\\HttpKernel->handleRaw() (Line: 81)\nSymfony\\Component\\HttpKernel\\HttpKernel->handle() (Line: 58)\nDrupal\\Core\\StackMiddleware\\Session->handle() (Line: 48)\nDrupal\\Core\\StackMiddleware\\KernelPreHandle->handle() (Line: 106)\nDrupal\\page_cache\\StackMiddleware\\PageCache->pass() (Line: 85)\nDrupal\\page_cache\\StackMiddleware\\PageCache->handle() (Line: 50)\nDrupal\\ban\\BanMiddleware->handle() (Line: 48)\nDrupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle() (Line: 51)\nDrupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle() (Line: 23)\nStack\\StackedHttpKernel->handle() (Line: 718)\nDrupal\\Core\\DrupalKernel->handle() (Line: 19)\n"name: "AjaxError"[[Prototype]]: Error

Steps to reproduce

  • composer require drupal inline_entity_form:2.0.0-rc7 -W
  • composer require drupal/eck:^2.0 -W
  • Navigate to admin/structure/eck
  • Select Add entity type; create an entity with Title base field
  • Add an entity to the new entity type you just created
  • Create an Entity reference field type on one of your content types under Manage fields; reference it to the entity you just created
  • Navigate to Manage form display on that content type
    • Change the new entity reference field you just created from Autocomplete to Inline entity form - Complex
    • Allow users to add new and existing entities and to edit entities
  • Navigate to the content type; add a new entity inline; edit that entity; notice no issues
  • Add the existing entity you created earlier; edit that entity; notice an AJAX issue

Proposed resolution

I'm not sure what the specific issue is, but it seems to have been introduced in 2.0.0-rc7.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @hannakras
  • πŸ‡©πŸ‡ͺGermany lmoeni

    I'm having the same issue that you described but for me it's when I reference a paragraph.
    I'm using the Paragraphs module and changed the entity reference form display to "Inline entity form - Complex".

    When I edit the entity reference field I get a AJAX error and this is what appears in the log:

    TypeError: menu_ui_node_builder(): Argument #2 ($entity) must be of type Drupal\\node\\NodeInterface, 
    Drupal\\paragraphs\\Entity\\Paragraph given in menu_ui_node_builder() (line 311 of core/modules/menu_ui/menu_ui.module).
     call_user_func_array('menu_ui_node_builder', Array) (Line: 307)\nDrupal\\Core\\Entity\\EntityForm->buildEntity(Array, Object) (Line: 155)\nDrupal\\Core\\Entity\\ContentEntityForm->buildEntity(Array, Object) (Line: 186)\nDrupal\\Core\\Entity\\ContentEntityForm->validateForm(Array, Object)\ncall_user_func_array(Array, Array) (Line: 82)\nDrupal\\Core\\Form\\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)\nDrupal\\Core\\Form\\FormValidator->doValidateForm(Array, Object, 'node_normal_page_edit_form') (Line: 118)\nDrupal\\Core\\Form\\FormValidator->validateForm('node_normal_page_edit_form', Array, Object) (Line: 593)\nDrupal\\Core\\Form\\FormBuilder->processForm('node_normal_page_edit_form', Array, Object) (Line: 325)\nDrupal\\Core\\Form\\FormBuilder->buildForm(Object, Object) (Line: 73)\nDrupal\\Core\\Controller\\FormController->getContentResult(Object, Object)\ncall_user_func_array(Array, Array) (Line: 123)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 583)\nDrupal\\Core\\Render\\Renderer->executeInRenderContext(Object, Object) (Line: 124)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)\nDrupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}() (Line: 166)\nSymfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object, 1) (Line: 74)\nSymfony\\Component\\HttpKernel\\HttpKernel->handle(Object, 1, 1) (Line: 58)\nDrupal\\Core\\StackMiddleware\\Session->handle(Object, 1, 1) (Line: 48)\nDrupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object, 1, 1) (Line: 106)\nDrupal\\page_cache\\StackMiddleware\\PageCache->pass(Object, 1, 1) (Line: 85)\nDrupal\\page_cache\\StackMiddleware\\PageCache->handle(Object, 1, 1) (Line: 48)\nDrupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)\nDrupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)\nDrupal\\Core\\StackMiddleware\\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)\nDrupal\\Core\\DrupalKernel->handle(Object) (Line: 19)\n", name: "AjaxError", stack: "@https://nrwgov.ddev.site/core/misc/ajax.js?v=10.1.2:196:32\n@https://nrwgov.ddev.site/core/misc/ajax.js?v=10.1.2:1889:3\n" }
    ajax.js:196:32
    

    This is not occuring when I create the entity reference.

    I can also confirm that this did not occur in 2.0.0-rc6 and seems to be releated to the changes in: https://www.drupal.org/project/inline_entity_form/issues/3375555 ✨ Add a FieldFormatter to display rendered menu Postponed

  • πŸ‡³πŸ‡ΏNew Zealand john pitcairn

    It's likely this is due to IEF now calling hook_entity_prepare_form(). There are a couple of other related issues:
    πŸ› Parent form entity builders run on IEF resulting in fatal errors Active
    πŸ› Error when referencing a non-revisioned entity in IEF on a revisioned edit form Active

Production build 0.71.5 2024