eca_form: Action "Form: add Ajax handler" creates one nesting div element per Ajax trigger

Created on 22 July 2025, about 1 month ago

Problem/Motivation

Action "Form: add Ajax handler" creates one nesting div element per Ajax trigger.

Steps to reproduce

  • Drupal installation with standard profile, install eca_form, eca_content and some other ECA sub-modules
  • Add a new select list options field to "page" content type called "field_myoptions". Add two options, for example "One" and "Two".
  • Create new ECA config, use "Build form" event for entity type "node" of bundle "page". Add an action as successor "Form: add ajax handler" for field name "field_myoptions" and set "Disable validation errors" to "Yes". Save this config.
  • Add a new "page" node via /node/add. Go to the edit page of the node. When selecting a value in "field_myoptions" you will notice that an Ajax throbber shows up as expected.

Now everytime the Ajax is triggered, the DOM creates another nested div element as a wrapper around the form (see attached screenshot).

Proposed resolution

The Ajax replacement method should probably be switched to replace instead of insert/html so that we don't get into possibly infinite nesting.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇩🇪Germany mxh Offenburg

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

Comments & Activities

  • Issue created by @mxh
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I'm not sure that this is an ECA bug as the ajax response is rendered by Drupal core in \Drupal\Core\Render\MainContent\AjaxRenderer::renderResponse and that has the InsertCommand hard-coded in it without any options to change that. Looks like this needs to be addressed in core, or do you know of any option to do that differently?

Production build 0.71.5 2024