11.08.2017 Views

codebright

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Forms 168<br />

1 <br />

2<br />

3 <br />

6 <br />

8 <br />

9 <br />

Reset Button<br />

The reset button can be used to clear the contents of your form. It’s used by your application’s users<br />

when they have made a mistake. Here’s an example of how to generate one.<br />

1 <br />

2<br />

3 {{ Form::open(array('url' => 'my/route')) }}<br />

4 {{ Form::reset('Clear') }}<br />

5 {{ Form::close() }}<br />

The first parameter to the Form::reset() method is the label that you would like to appear on the<br />

button. Here’s the generated source from the above example.<br />

1 <br />

2<br />

3 <br />

6 <br />

8 <br />

9 <br />

Form Macros<br />

In the previous subsection we discovered the various form input generator methods. They can be<br />

used to save you a lot of time, but perhaps you have a custom type of form input that is specific to<br />

your own applications.<br />

Lucky for us, Taylor already thought about this. Laravel comes equipped with a method that will<br />

allow you to define your own form generators, let’s see how it works.<br />

So, where shall we put our form macros? Ah I know, let’s make a file called app/macros.php, then<br />

we can include it from within our routes file. Here’s the contents:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!