11.08.2017 Views

codebright

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Forms 167<br />

Normal Buttons<br />

When we need a button that won’t be used to submit our form, we can use the Form::button()<br />

method. Here’s an example.<br />

1 <br />

2<br />

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

4 {{ Form::button('Smile') }}<br />

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

The parameters for the Form::button() method are exactly the same as the Form::submit() method<br />

mentioned previously. Here’s the generated source from the example.<br />

1 <br />

2<br />

3 <br />

6 <br />

8 Smile<br />

9 <br />

Image Buttons<br />

Instead of a native button, you could use the HTML5 image button type to submit your form. Here’s<br />

an example.<br />

1 <br />

2<br />

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

4 {{ Form::image(asset('my/image.gif', 'submit')) }}<br />

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

The first parameter to the Form::image() method is the URL to an image to use for the button. I<br />

have used the asset() helper method to generate the URL. The second parameter is the value of the<br />

button.<br />

Here’s the generated source code.

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

Saved successfully!

Ooh no, something went wrong!