Simple question, I hope.
I need to add a default value to my select list 'Please Select', and set it to disabled.
<select name="myselect" id="myselect">
<option value="" disabled>Please Select</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
</select>
My current laravel form::select is
{{
Form::select(
'myselect',
$categories,
$myselectedcategories,
array(
'class' => 'form-control',
'id' => 'myselect'
)
}}
How can I amend this to include the default option value?
In Laravel 5.1 you can prepend the default item if the list is a collection (result of a Eloquent::lists()
)
$categories = Category::lists('name', 'id');
$categories->prepend('None');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With