Multi Steps Forms - How to reset 'steps' variable

I have a Multi Step Form following this tutorial Creating Multi Steps Forms

In my case the form is an Update Form in an SPA and has 8 steps. Here is my scenario…

  • The user enters the form via a link ‘id=15’ and gets to step 3.
  • They then go off to another page, not bothering to save any changes.
  • They enter the form again but via a different link, this time ‘id=37’.
  • The data shown in the form is correct BUT they are taken straight to Step 3 rather than back to the beginning of the form at Step 1.

How do I set the value of the variable ‘steps’ to 1?
I thought I could set it in the Server Action, but this doesn’t work.

image

Instead of using a variable, that looses its value when going to a different page, use session or local storage to keep track of the steps.

Hi @ben, the problem is that it’s not losing it’s value, it’s retaining it. I want to reset it back to 1 in this example.

Sorry, I misread the question. Worse still, I have no idea of how to help except to say that there has to be a trigger that resets the value. Maybe re-entering the page you could reset the value. Just an idea from a different angle. Hope it helps somehow. :crossed_fingers:

1 Like