One of the most basic aspects of any web application is the form. Laravel provides easy ways to build HTML for our forms.
To complete this recipe, follow these steps:
In the
app/views
folder, create a newuserform.php
file.In
routes.php
, create a route to load the view:Route::get(userform, function() { return View::make('userform'); });
In the
userform.php
view, create a form using the following code:<h1>User Info</h1> <?= Form::open() ?> <?= Form::label('username', 'Username') ?> <?= Form::text('username') ?> <br> <?= Form::label('password', 'Password') ?> <?= Form::password('password') ?> <br> <?= Form::label('color', 'Favorite Color') ?> <?= Form::select('color', array('red' => 'red', 'green' =>'green', 'blue' => 'blue')) ?> <br> <?= Form::submit('Send it!') ?> <?= Form::close() ?>
View your...