In this episode, we finally get hands-on and build the core of our form! We start by cleaning up the sample code, replacing the old counter with a real HTML <form>
, and centering our content in a nicely sized container. The form itself consists of a text input (for our intended URL) and a button labeled "Get short URL."
We hook up actual state handling to this input so that we can keep track of what the user types. Then, we wire up a submit handler to the form so that when it's submitted, some logic actually happens. Of course, what good is a form without validation? So we bring in Laravel-style validation rules for instant feedback—if the input is empty, you'll see an error message right away. We even improve validation by requiring the input to be a proper URL.
Once the basic functionality is in, we shift gears and start working on the design. We copy over some handy Tailwind CSS utility classes (all available in the course repo), install the Tailwind forms plugin for cleaner defaults, and tidy up the layout so the button and error messages look nice.
Before wrapping up, we throw in a placeholder for the input and make some final visual tweaks so everything looks clean. Next time, we're going to do a little refactor to move form logic into its own dedicated class, making our code a lot cleaner—especially as more features get added.