In this episode, we dig into a pretty common UX problem: what happens when a user goes back a step in a multi-step form? Specifically, we're working with a product creation flow. When we hit the "next" button, we create a new product in the database, but if we go back and change something (like the title), hitting "next" again just ends up creating another product – oops, not what we want!
You'll see a practical walkthrough of how this double-submit bug happens, and then we work through the process of fixing it. We look at ways to check if a product already exists in our form state, using helper methods and Laravel's filled
function, so we can decide whether to create a new product or just update the existing one.
By the end, you'll have a much cleaner approach: if there's already a product in state, we update it; otherwise, we create it as new and store its ID. You’ll also get a sneak peek at the next big challenge – handling going back with more complex data like uploaded images. Stay tuned for that in the next episode!