ECA Form breaks complex IEF widget

Created on 22 August 2024, 6 months ago

Problem/Motivation

When eca_form is enabled, even if there isn't a single eca model, the inline_entity_form (IEF) complex widget breaks such that the user can no longer add new entities with that widget.

Steps to reproduce

  • Install Drupal 10.3,2 and install a new site with the standard profile
  • Enable eca_form and inline_entity_form (3.3.0-rc20)
  • Add a field to article that references a node of type page
  • Configure the form to use the complex IEF for that entity reference, allow to create new entities and to select existing entities
  • Create a new article and add a new reference, add a title and create that embedded entity: no entity appears in the table

To test the opposite, disable eca_form and create another article. Now this works as expected.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

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

Merge Requests

Comments & Activities

  • Issue created by @jurgenhaas
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The error is caused by \Drupal\eca_form\HookHandler::inlineEntityFormAfterBuild. When I disable that callback by inserting a return $form; into the first line of it, the error disappears.

    The problem is that IEF is not creating the correct embedded entity, at the same time there are no error messages or exceptions whatsoever.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Also, selecting an existing entity in such complex IEFs doesn't work either. See also πŸ› Nested IEF (complex form) stopped working for inner form Active .

    A matter of fact, IEFs with the simple widget are not affected.

    I'll start with an MR to disable the hook handler for complex IEFs so that people can use that patch until we've found a proper solution for this.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Turn out, when we revert the "bugfix" from πŸ› An error occurred while trying to build an inline entity from submitted form values Fixed then the issue disappears as well.

  • Status changed to Needs work 6 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I've now disabled that code block from the other bug fix, but only for complex IEF widgets. This is just a workaround, but that can be applied to avoid that issue for now.

  • Pipeline finished with Success
    6 months ago
    #261606
  • Pipeline finished with Success
    6 months ago
    #261785
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I have now disabled that complex widget hook entirely until we get a solution for this.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Turns out, disabling complex widgets entirely breaks some existing models, that otherwise with the workaround from the MR would be OK.

    So, we're now merging and back porting the MR, publish another bug fix release and then hope that we can still find a proper solution for the underlying problem. But at least we would not be breaking anything in the meantime.

  • Pipeline finished with Skipped
    6 months ago
    #265733
  • Pipeline finished with Skipped
    6 months ago
    #265734
  • πŸ‡¬πŸ‡§United Kingdom lexsoft London

    @jurgenhaas

    Upgrading ECA from version 1.x to 2.x on Drupal 10.3.7 generates a warning related to the use of eca_form alongside inline_entity_form 3.x when initializing content entities using the complex widget with AJAX. The warning message displayed is:

    β€œAn error occurred while trying to build an inline entity from submitted form values. This might be a problem if you are using ECA to extend inline entity forms. Please report this to the ECA issue queue to help us improve it.”

    Upon investigation, it appears that the condition in the code checks for:

    if ($form['#eca_ief_info']['widget_plugin_id'] !== 'inline_entity_form_complex') {

    However, in our case, we are using the IEF Table View Mode module https://www.drupal.org/project/ief_table_view_mode β†’ . I would like to suggest modifying this condition to use a regular expression that matches inline_entity_form_complex, which would also account for custom plugins. This change could help ensure broader compatibility.

  • πŸ‡¬πŸ‡§United Kingdom lexsoft London

    lexsoft β†’ changed the visibility of the branch 3469697-eca-form-breaks to hidden.

  • πŸ‡¬πŸ‡§United Kingdom lexsoft London

    I'm having the same issue as @jurgenhaas described in https://www.drupal.org/project/drupal/issues/3405115 πŸ› Argument #1 ($values) must be of type array, null given. Postponed: needs info
    Is there a Drupal core patch fix for it?

  • Pipeline finished with Failed
    3 months ago
    Total: 632s
    #364291
  • Pipeline finished with Failed
    3 months ago
    Total: 820s
    #364318
  • Pipeline finished with Failed
    3 months ago
    Total: 747s
    #364360
  • Pipeline finished with Failed
    3 months ago
    Total: 6280s
    #365587
  • Pipeline finished with Success
    3 months ago
    Total: 696s
    #367804
  • Pipeline finished with Success
    3 months ago
    Total: 809s
    #367825
  • Pipeline finished with Success
    3 months ago
    Total: 3143s
    #367833
  • Pipeline finished with Success
    2 months ago
    Total: 211s
    #372178
  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    We are hitting this issue on a bunch of sites -- or rather πŸ› Integrity constraint violation when trying to add multiple blocks in a complex IEF field Active , which I did not think ECA had anything to do with until someone left a comment there about ECA. All of the affected sites have ECA enabled. Here's the gist of what we're doing:

    1. Install IEF, ECA Form modules
    2. Create a "featured block" entity reference field on a content type, e.g. "Basic Page", referencing content blocks.
    3. Set the field to use the complex IEF widget
    4. Create a new page, and create a new block using the IEF widget.

    If you save now, everything is fine. If you edit the page and add another block, it works fine -- so long as you only ever add one block at a time.

    5. If you add a second block without saving the node, it appears correct -- it adds another row to the IEF widget, and you can keep adding more.
    6. But if you save, you get the Integrity Constraint Violation, duplicate entry 'xxx' for key 'node__field_uuid_value'.

    This is affecting node and taxonomy term references as well as block references -- anywhere the IEF complex widget is used with multiple cardinality, if eca_form module is enabled. Doesn't matter if there's an ECA model using it.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thanks @freelock for the analysis. I will have to debug this, and it reminds me of πŸ› Entity Form: Build Entity can't process unlimited values Active which also has some strange behaviour for multi value fields.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    That issue does sound very similar. One difference is that we were seeing the issue with limited cardinality, too -- although a cardinality of 6... but I'm guessing if ECA is replacing the form_state for some reason that might do it...

Production build 0.71.5 2024