vendredi 27 février 2015

Get all checked checkboxes values


i have the following form:



<%= form_for([company,service], :remote => true) do |f| %>
<%= health_care_insurances.each do |hc_insurance| %>
<label><%= hc_insurance.name %></label>
<input id="health_care_insurance_<%= user.id %>" name="<%= hc_insurance.id %>" value="<%= hc_insurance.id %>" type="checkbox"><br/>
<% end %>
...
<% end %>


When it's submited, and for the sake of good performance, i would like to get an array with all "hc_insurance.ids" that are checked. I know i might use javascript to add them to a hidden_field and then pick them up from there, but im not sure that's a good way to go.


Is there any rails way to pick them up from the controller?





Aucun commentaire:

Enregistrer un commentaire