Search code examples
laravellaravelcollective

Default value for laravel collective select


I have a Laravel collective select as follows:

{!! Form::select('phone', $numbers, $title, ['class' => 'phone-select2 col4', 'id' => 'phone']) !!}

I want to pass default value for dropdown as separate variable from $numbers. So, have passed it as $title but it is didn't work due to it is not in the $numbers. So, how can I pass default value for it?


Solution

  • What you're looking for is a placeholder. enter image description here https://laravelcollective.com/docs/6.x/html#drop-down-lists

    According to the documentation, you can set the default value to null and provide placeholder attribute as part of the fourth argument:

    ['class' => 'phone-select2 col4', 'id' => 'phone', 'placeholder' => 'Pick an option']