Answer the question
In order to leave comments, you need to log in
How to set custom html attributes for options for a simple_form dropdown list?
I'm using gem simple_form in the project. Generate dropdown list:
<%= f.input :region, :collection => GeoObjects.regions,
:label_method => lambda { |i| i.name },
label: 'Регион' %>
<select class="select required" required="required" aria-required="true" name="adv[region]" id="adv_region"><option value=""></option>
<option value="0">Московская область</option>
<option value="1">Ленинградская область</option>
<option value="2">Мордовия</option></select>
<select class="select required" required="required" aria-required="true" name="adv[region]" id="adv_region"><option value=""></option>
<option value="0" lattitude="55.5" longitude="37.3">Московская область</option>
<option value="1" lattitude="54.53" longitude="34.345">Ленинградская область</option>
<option value="2" lattitude="53.3" longitude="34.3334">Мордовия</option></select>
Answer the question
In order to leave comments, you need to log in
It is necessary to form data for the list in a different way, collection:
you need to pass in the parameter:
[
['Московская область', 0, { lattitude: 55.5, longitude: 37.3 }],
['Ленинградская область', 1, { lattitude: 54.53, longitude: 34.345 }]
...
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question