How would i add a data attribute to a laravel {{Form::select}}
array?
For example, I want each of my options to look like this
<option value="1" data-days="182">6 Months</option>
<option value="2" data-days="365">1 Year</option>
How do I add the data attribute in the following select array?
Days Table
id | days | name
1 | 182 | 6 Months
2 | 365 | 1 Year
View
{{Form::select('amount_of_days', $days, null, ['placeholder' => 'Amount of days'])}}
For this requiment you need to create the <option>
with loop and simply html
<select name="amount_of_days" placeholder="Amount of days">
@foreach($days as $val)
<option value="{{ $val['id'] }}" data-days="{{ $val['days'] }}"> {{ $val['name'] }}<option>
@endforeach
</select>