Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

johnny94's avatar

Best practice for creating multiple step form

Hi, I am creating a multiple steps form. I store user's input data temporarily and pass it from one step to the next step. Each step is in different view. I use the 'withInput' function to pass data when redirect to next step. Finally, the data will be save to database until user complete the last step.

Although I have done this, my current implementation seems difficult to maintain. Is there any best practice for creating this kind of form in laravel?

0 likes
4 replies
kfirba's avatar

@johnny94 You can always use JavaScript to do that for you. With JS you can change the part of the form that is being currently shown and when you reveal the last part of the form, show a submit button that will submit the whole form. This way, you only need 1 endpoint in your application to handle the whole form.

1 like
martinbean's avatar
Level 80

@johnny94 You could save the data to a session in between page views, or to a database keyed on a request ID (which could even be the session ID). Then when the user gets to the last page and submits the form, either grab all the data from session or database (plus the data from the last page), and do whatever you need to with it, whether that be save it to another database table, send it to a recipient via email etc.

1 like
sukonovs's avatar

Form my experience database solution is the most flexible. You can delete invalid data after with cron.

Please or to participate in this conversation.