Pass attributes to a form element

Submitted by ramirors - 10 years ago

When you need to pass more attributes to a form element using blade syntax.

// PASSING CLASS, ID, PLACEHOLDER AND DISABLED ATTRIBUTES TO A input text elemet
{{ Form::text('name', $value = null , $attributes = ['class' => 'form-control', 'id' => 'myid', 'disabled' ,'placeholder' => 'Email']) }}

//PASSING CLASS AND ROWS
{{ Form::textarea('name', $value = null ,$attributes = ['class' => 'myTextArea', 'rows' => '5']) }}

//SELECT ELEMENT PASSING AND ARRAY OF OTIONS, ID AND CLASS
{{ Form::select('name' , ['1' => 'OPTION 1', '2' => 'OPTION 2'], $selected, $attributes = ['class' => 'myClass']) }}

//PASSING TO A PASSWORD ELEMENT
{{ Form::password('name', $attributes = ['class' => 'form-control', 'id' => 'myid']) }}

NOTE:
    I´m using brackets syntax for arrays ['' => '']