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

panthro's avatar

Inertia - what to return to the form helper?

I have a large form.

I have split it into several smaller forms which are shown and hidden inside a page depending on what step a user is on.

When one form is completed the user clicks next and the form is validated using a form request, if successful, the step is increased showing the next form.

I have defined these validation endpoints like this:

Route::post('/products/validate-step-one', fn StepOneRequest $request) => ?????);

With the idea being, they are hit, and then the from request does the validation and kicks back errors, but if the form request passes, I do not know what to return.

I do not want a redirect, as I want to stay on the same page.

Route::post('/products/validate-step-one', fn StepOneRequest $request) => false);

The above works, but feels wrong.

0 likes
2 replies
martinbean's avatar
Level 80

@panthro I think you’re over-complicating things. If there are different steps, then create separate views and controllers for those steps.

For example, a checkout might be split into billing, shipping, and payment steps. There’s nothing wrong in having dedicated views and controllers for those individual steps, i.e. Checkout\BillingDetailsController, Checkout\ShippingDetailsController, etc.

1 like

Please or to participate in this conversation.