Preserve modified values when going back

Created on 22 July 2024, 4 months ago
Updated 25 July 2024, 4 months ago

Problem/Motivation

When a multistep form is configured, when the user modifies one step and goes back, the modified values are lost once he/she comes back to the next step.

Steps to reproduce

  1. Create a content type with title and body.
  2. Create two filed groups of type From step, the second with the back button enabled.
  3. Place the title in the first step, and the body in the second step.
  4. Create a node of that type, set the title, and go to the next step.
  5. On this second step, modify the body's content, and click back.
  6. On the first step, click next to go back to the second step.
  7. The body is empty.
  8. The step field values are saved just if the next button gets clicked. Any change in the step is lost if the back button is clicked.

Question

Is there any configuration or way to keep the updated values when the back is clicked?

Thanks

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain espurnes

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

Comments & Activities

  • Issue created by @espurnes
  • 🇪🇸Spain espurnes

    After some digging I was not able to keep the $form[$child_id]['#access'] = FALSE; in the MultistepController rebuildForm method and preserve the updated step fields values when going back to the previous step.

    So, even if it is not the best option, I decided to add a new configuration (use_hidden_flow) at step level to change the $form[$child_id]['#access'] = FALSE; by a $form[$child_id]['#attributes']['class'][] = 'hidden';.

    If in a form with 3 steps, we enable the use_hidden_flow, all the fields will be rendered (but hidden with css) on each step.

    If in step 2, when going back to step 1, the step 2 changes are applied. So, when returning to step 2 the fields do have the previous values.

    If the new parameter use_hidden_flow is not enabled, the module continues working as before.

  • 🇪🇸Spain espurnes

    Patch with the previously described changes.

Production build 0.71.5 2024