informed icon indicating copy to clipboard operation
informed copied to clipboard

Questions when using multiStep form with dynamic steps/pages

Open calebklc opened this issue 6 years ago • 9 comments

Hi,

I am creating a multi-step form with dynamic steps/pages and facing some problems.

Here is the simplify code. https://stackblitz.com/edit/react-kw8ntc

The scenario of my case is

  1. Fill Reference No.,
  2. Check Step 3, then click Next
  3. Fill all fields, then click Previous
  4. Uncheck Step 3, check Step 4, then click Next
  5. Fill all fields, and click Submit.

The form cannot be submitted. I think it keeps Step 3 error status.

I tried to remove the statuses by using setValue, setTouched, setError but it seems not working.

My questions are:

  1. Is it a correct way to reset status(values and errors) for specific fields?
  2. Is there any simple way to remove the whole (step/page)'s values?
  3. Is there any way to set keepState to the Step/Page instead of fields?
  4. What is the purpose of setting step on the field?

Sorry to bother you with so many questions, but thank you for your patience.

calebklc avatar Feb 25 '20 08:02 calebklc

So first your not using the step field correctly. The step field should be a static number that lets informed know what step that field is on. That was it knows if it needs to validate the field

joepuzzo avatar Feb 25 '20 10:02 joepuzzo

Also the use case is interesting. Its basically dynamic steps. I need to look into this and build an example.

joepuzzo avatar Feb 25 '20 10:02 joepuzzo

So first your not using the step field correctly. The step field should be a static number that lets informed know what step that field is on. That was it knows if it needs to validate the field

I see...

Also the use case is interesting. Its basically dynamic steps. I need to look into this and build an example.

Thanks. I will wait for your example.

calebklc avatar Feb 25 '20 12:02 calebklc

Ok so I got you! I have refactored and added some cool shit! Stand by for another 20 minutes and I will update the docs!

joepuzzo avatar Feb 25 '20 14:02 joepuzzo

Done! https://joepuzzo.github.io/informed/?path=/story/multistep-forms--complex-multistep

joepuzzo avatar Feb 25 '20 14:02 joepuzzo

Thank you so much and I will give it a try tomorrow :))

calebklc avatar Feb 25 '20 15:02 calebklc

Finally, I implemented this approach into my project and it works pretty well.

I really like the setCurrent function, it's so handy with my step navigation menu.

Thank you so much.

calebklc avatar Feb 26 '20 12:02 calebklc

Glad I could help!

joepuzzo avatar Feb 26 '20 13:02 joepuzzo

Done! https://joepuzzo.github.io/informed/?path=/story/multistep-forms--complex-multistep

Is this functionality still available I get redirected whenever I use the link.

PhilObi avatar May 14 '21 23:05 PhilObi