Support Request: How to properly "re-build" the entity with a multistep form

Created on 1 December 2023, 12 months ago
Updated 2 December 2023, 12 months ago

Problem/Motivation

Please forgive me if this is covered elsewhere or if it just plain out of scope for this module.

I am attempting to integrate the IEF element with a custom multistep form framework we are developing. Our forms are essentially using tabs that the users can generally move back and forth between. We have a storage mechanism to maintain the growing $form_state->values array as they populate fields on each tab of the form.

When the user navigates to tab2, there is a regular formSubmit process and then a form rebuild before rendering the form for tab2. We have this working (fairly) smoothly for all our use cases so far.

The important part here is that the IEF element is only displayed on tab1. The IEF element is not part of the form when the user is on tab2.

I have confirmed that the $form_state values are changed from the first form submit, when navigating to tab2, and I have confirmed that the $form_state values remain correct when building tab2.

Let's call the original state of the entity as version0. The first modification, made on tab1, will be version1.

I have also observed that when I return to tab1 for the first time, the IEF element shows the altered values I originally put in. So, entity values from version1 are used when I return to tab1.

Problems start when I alter IEF element values again on tab1, navigate to tab2, and then back again to tab1. Let's call this version2 of the entity. At this point, the IEF element only shows the first round of value alterations and not the second round. Interestingly, it's version1 of the entity and not version0 that is used to populate the IEF element.

I know the root cause of this problem is that the IEF element is not built on tab2. I can actually test this by putting the IEF element on tab2 and I am able to continuously modify IEF element form values if I have the IEF element on both tabs.

I guess what I need to try and figure out is:
How do I force the IEF element form to build with the current form_state values and not the stale version1 of the entity.

I am hoping there is something obvious I am missing in my investigation. Is it odd that the stale version1 is used instead of the original version0? There is no entity save happening. (yet)

πŸ’¬ Support request
Status

Active

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States JonMcL Brooklyn, NY

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

Comments & Activities

  • Issue created by @JonMcL
  • πŸ‡ΊπŸ‡ΈUnited States JonMcL Brooklyn, NY
  • πŸ‡ΊπŸ‡ΈUnited States JonMcL Brooklyn, NY

    I was thinking of simplifying my question:
    Where does the IEF element set the new values, taken from $form_state, into the form elements?

    If I can find the code, I can maybe determine what else we need to do to our multistep framework to make it compatible with the IEF element.

Production build 0.71.5 2024