Reputation: 5632
I'm using Laravel forms. This is my code in view.
<?php
$options = $items->pluck('name', 'id')->toArray();
$options[''] = "Choose...";
?>
{!! Form::select('item_id', $options, array('class' => 'form-control')) !!}
@error('item_id')
<div class="alert alert-danger">{{ $message }}</div>
@enderror
But unfortunately browser does not render css class,
<select name="item_id">
....
</select>
Upvotes: 0
Views: 345
Reputation: 3040
The third parameter for the form is the selected option, so you need to pass the array with the classes as a fourth argument. For example:
{!! Form::select('item_id', $options, null, array('class' => 'form-control')) !!}
Upvotes: 4