Using multi-step form + Server side Validate > How to focus on invalid step / input?

Hi,
I’m working on a registering form with 5 steps.
I setted up 2 validate in my Server Action (with conditions below):

  • email already exist in user table
  • company already exist based on $_POST.input_SIRET.value

Everything works well, BUT i would like to display the specific step depending on the validate feedback, so the user can see the validate message and input to correct whithout clicking on previous steps.

I tried adding a set value but this does not work.
What is the best way to proceed?

Many thanks

up.

Validation will stop the Server action running so you won’t be able to use the Set Value. I would suggest that you only progress to the next step (I assume you are using a variable on your page) using the Dynamic Event for Success of the server connect form.

That way, your form will only progress to the next step if the form succeeds and should show the validation message - no ‘back’ button required.

Hi @bpj ,
Thanks for your answer.
Yes i use a step variable + 1 form + 1 API. I load my form SC at the last step and run the API (2 validates, lot of insert in various tables and email).
Do I need to cut my SC in five SCs? or do i need to add conditions and run parts of the script according to step value?
Could you precise me the right/best way :wink: ?
Many thanks

There’s pros and cons with splitting into separate SCs. I would probably split, though, especially if you want to check for previous values in the DB.

What you could do is have a SC form to take an email and company which just does validation. If successful, moves the form on. The final form has hidden values that are bound to the email/company values from the first form. This final form is the one you submit to do your inserts etc.

1 Like

Many thanks for your advice.
Let’s think about that and move forward.

1 Like