eca_form: Find a better integration for Paragraphs and Inline Entity Form

Created on 26 May 2023, about 1 year ago
Updated 26 September 2023, 9 months ago

Problem/Motivation

Working with paragraphs in content forms using eca_form components does work, however only from the top-level. That means, if you want to manipulate paragraph form field elements, then you'd need to address them from the level of the form where the paragraph is being embedded (most notably in node forms).

This is technically working, but not ideal from UX perspective. It would be great being able to adjust field elements on the definition level of paragraphs, so that these definitions are working for all of them. Right now, you can only achieve this by looping over the referenced paragraph items of content and the set the form field elements one-by-one. Definetly not ideal.

Steps to reproduce

Proposed resolution

Maybe we introduce one or more new events for embedded paragraphs in content entity forms. Could also be done in a separate contrib integration module (maybe eca_paragraphs).

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

1.2

Component

Miscellaneous

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 mxh Offenburg
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Are paragraphs not embedded with inline_entity_form? Maybe we can extend support on that, so that this will be an enhancement for all sorts of embedded entities, not only paragraphs?

  • 🇩🇪Germany mxh Offenburg

    Paragraphs is not using IEF. Any module may add its own logic how to embed entity forms into other forms. Therefore I think it's not possible to find a "one-fits-all" solution here.

  • 🇩🇪Germany mxh Offenburg

    IEF currently also not really well supported, as can be seen here https://www.drupal.org/project/eca/issues/3348429#comment-14973259 📌 eca_form: Impossible or hard to identify an inline entity form Fixed

    So we could at least try to cover IEF and Paragraphs.

  • 🇩🇪Germany mxh Offenburg

    Another idea that came up when discussing this internally: We may also provide additional events to react upon when an EntityFormDisplay handler is being invoked for buildForm. Such event would probably already cover IEF and Paragraphs at the same time, however it would be an additional event and we maybe need to decorate the FormBuilder service or even the EntityFormDisplay handlers.

  • Assigned to mxh
  • 🇩🇪Germany mxh Offenburg

    Trying to work on an approach as mentioned in #6.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    286 pass
  • @mxh opened merge request.
  • Issue was unassigned.
  • 🇩🇪Germany mxh Offenburg

    I had to do the following:

    • Removed the Inline Entity Form related functionality as it was not working right. It was triggered on that hook but it then dispatched the event using the parent entity. Not what you'd expect and then it was wrongly dispatched for events that were intended for the parent entity but not for the entity of the inline entity form. So I had to remove it. And there is no update hook possible to move existing usages of that, because it cannot be differentiated between real intended parent events and inline events. So if anyone was using this, it was wrong anyway and needs to be manually adjusted then. Also remove that condition checking whether current form is inline entity form because it was using wrong circumstances.
    • Reacted upon hooks that are fired up by inline_entity_form module widgets and paragraph widgets. Then had to add further logic for inline_entity_form for being able to work with the entity using latest submitted values. So further logic was written for it to achieve that.
    • Introduced completely new event solely for Inline entity form building the form. It is dispatched for both inline_entity_form but as well for paragraphs. Despite paragraphs having nothing to do with inline_entity_form, that new event also works for that.

    Created first MR for having a patch file.

    Tests need to be added, and requires further manual testing.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    286 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    286 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    287 pass
  • Status changed to Needs review about 1 year ago
  • 🇩🇪Germany mxh Offenburg
  • Status changed to RTBC about 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This looks great, thanks @mxh for all your work on this.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    287 pass
  • Status changed to Fixed about 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 10 months ago
  • 🇳🇵Nepal bibhor

    Hi friends,
    Since this is a discussion about the IEF, I am posting my request here. Please accept my apology if this is not the right place.

    I have trouble calculating values from the inline entity form fields and showing them on the parent form.
    Using the Tamper:Math, I was able to calculate sub-totals within the inline forms as described by @jurgenhaas in this video.

    I wonder how to sum up the sub-total values from the IEFs and set it to the grand total field of the parent form using ECA.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Sorry @BibhOr this question almost got lost since the issue had been closed before. It's not really the best place to post "related" questions in existing issues, and certainly not in closed issues. Creating new issues is "free of charge", so don't hesitate to create new ones at any time. It's then easier for all of us to focus on that specific request, and later it will be easier for others to find that again, should anyone have a similar issue.

    When you report your support request in a new issue, it would be helpful if you described how you've approached your solution, i.e. which event is being used and how you grab the values that you sum up into sub-totals and why that is difficult for the grand total then. In other words, what have you tried to make it work and where exactly lies the challenge. If it helps to explain, you can always upload a simplified ECA model that hopefully helps us to reproduce the issue and use it to build a solution together with you then.

Production build 0.69.0 2024