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)