0

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?

apokryfos
  • 38,771
  • 9
  • 70
  • 114
  • The default selected value of a select must be in the dropdown list otherwise how would you have it selected as a default value? – apokryfos Apr 26 '21 at 11:12
  • It is special case.for an example if we have very first user, there is no data for dropdown. but as the requirement of our business case, it should give default value for dropdown which is configured already. – Jounior Developer Apr 26 '21 at 11:30

1 Answers1

2

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']

Ozwild
  • 46
  • 5