Reputation: 19705
This line of code:
{!! Form::select('fightingAreas', [1,2,4,8], old('fightingAreas'),['class' => 'form-control']) !!}
Generates :
<select class="form-control" id="fightingAreas" name="fightingAreas">
<option value="0" selected="selected">1</option>
<option value="1">2</option>
<option value="2">4</option>
<option value="3">8</option>
</select>
I would like to generate a value that is equals to text:
<select class="form-control" id="fightingAreas" name="fightingAreas">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="4">4</option>
<option value="8">8</option>
</select>
Is it posible to do it with Form::select()???
Upvotes: 1
Views: 803
Reputation: 2820
Its actually easier than you think
{!! Form::select('fightingAreas',
['1'=>1,'2'=>2,'4'=>4,'8'=>8],
null,['class' => 'form-control'])
!!}
Also using null will automatically select the old value no need to set old('fightingAreas')
For more info have a look at
http://laravel-recipes.com/categories/21
https://laravelcollective.com/docs/5.2/html
Thanks
Upvotes: 2