Creating Textarea Input Field in Laravel

To generate a textarea element in Laravel we need to use Form::textarea() method.

See Also: Creating a text input field in Laravel

To output a textarea field in view template, use the following code.

{{ Form::textarea('summary') }}

The Above code will produce following HTML output.

<textarea name="summary" cols="50" rows="10"></textarea>

To set the default value pass second parameter,

{{ Form::textarea('summary', 'lorem ipsum') }}

This will ouput,

<textarea name="summary" cols="50" rows="10">lorem ipsum</textarea>

HTML attributes like class, id etc can be provided as a third argument in form of an array.

{{ Form::textarea("summary", null, ['class' => 'form-control', 'id'=>'user_summary']) }}

This will generate following HTML output,

<textarea class="form-control" id="user_summary" name="summary" cols="50" rows="10"></textarea>





Leave a Comment.