php - Use data attributes in laravel form select
995
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'])}}
Answer
Solution:
The best way to set the custom value to the form::select is by using the attribute parameter of form::select function.
controller.php
blade.php
Answer
Solution:
For this requiment you need to create the
<option>
with loop and simply html