In this episode, we're tackling a key part of any multi-step form: actually moving between the steps! We start by setting up the most basic navigation, just using a wire:click
on the "Next" button. However, that's not best practice for real world forms, so we quickly shift to a more robust (and proper) way—submitting the form and using a method in the component to validate and then proceed to the next step.
We walk through how to add validation for each step (like making the title required) and only moving forward if everything checks out. You'll see how to hook up your form fields (e.g., wire:model
) so your data flows smoothly.
The episode also covers how to set up your other steps in the same way—so, for example, your "description" step looks a lot like your "title" step. Beyond just going forward, we check out how you can programmatically jump to specific steps, and how step components are named and structured.
Lastly, we add a Back button and wire that up so users can move back to previous steps, and discuss a couple of small things (like setting button types) to smooth out the UI experience. We wrap it up with a quick mention of "state" management (which we'll dive into in the next lesson!), so you know where all your form data is stored and how it'll be used in the final step.
So by the end of this video, you'll know how to navigate users smoothly back and forth through your wizard-style form, validating along the way!