Reputation: 15016
I am using Laravel 5.1. In form I am generating drop down as:
{!! Form::select('ptype', $p_types,null,['class' => 'form-control text-capitalize']) !!}
While in controller $p_types
is set as:
$p_types = PType::lists('name', 'id');
I want to show an option as Select here
on top of drop down. How do I do tat?
Upvotes: 0
Views: 79
Reputation: 2284
You can also do like this in blade template to add the Select here
option on top of drop down
{!! Form::select('ptype',([''=>'Select here']+$p_types->toArray()) ,null,['class' => 'form-control text-capitalize']) !!}
Upvotes: 0
Reputation: 356
There is no simple solution to doing what you're asking, as mentioned here. Form:recipes add placeholder attribute What you can do is in the lists method insert a record into the collection before it's passed to the blade template. Checkout this link Collection Methods. That is by far the easiest solution.
$p_types->push("Select Here");
Upvotes: 2