Laravel 4 blade drop-down list class attribute

Gravy picture Gravy · Aug 30, 2013 · Viewed 40.7k times · Source

Laravel blade drop down list class attribute not working.

I cannot find any reference to class or assigning attributes to select / drop-down lists in the documentation.

http://www.laravel.com/docs/html#drop-down-lists

Examples tried:

{{ Form::select('product_id', $productList, array('class'=>'form-control')) }}

{{ Form::select('product_id', $productList, $attributes = array('class'=>'form-control')) }}

Both return the same html but without the class attribute:

<select id="product_id" name="product_id">
    ... Option Stuff ...
</select>

Answer

Bastian Hofmann picture Bastian Hofmann · Aug 30, 2013
{{ Form::select('product_id', $productList, null, array('class' => 'form-control')) }}

The third parameter is the key of the currently selected option. Defaults to null.