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 158<br />

1 <br />

2<br />

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

4 {{ Form::label('first_name', 'First Name') }}<br />

5 {{ Form::text('first_name', 'Taylor Otwell',<br />

6 array('id' => 'first_name')) }}<br />

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

The truth is, every single one of the input generators will accept an optional array of attributes as<br />

a final parameter. They all work in the same way, so I won’t describe this feature in every section.<br />

Just keep it in mind!<br />

Textarea Fields<br />

The textarea field functions in a similar way to the text input type, except that they allow multiline<br />

data. Let’s see how they can be generated.<br />

1 <br />

2<br />

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

4 {{ Form::label('description', 'Description') }}<br />

5 {{ Form::textarea(‘description', 'Best field ever!') }}<br />

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

The first parameter is the name attribute for the element, and the second parameter once again is the<br />

default value. Here’s the form element as it appears in the generated HTML source.<br />

1 <br />

2<br />

3 <br />

6 <br />

8 Description<br />

9 Best field ever!<br />

13 <br />

As you can see from the generated source, Laravel has provided some default values, such as the<br />

amount of columns and rows for the field. We could easily override these values by adding new<br />

values for them to the optional final parameter. I hope you haven’t forgot about the attributes array!

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

Saved successfully!

Ooh no, something went wrong!