I have Rails 4 and Parsley-Rails installed.
My form has multiple checkboxes,user needs to check at least 3 to save form in database..
But my code don't work. It checks all checkboxes by default.
My form:
<%= form_for(@advertisement, :html => {"data-parsley-validate" => true,:multipart => true},remote: true, format: :json) do |f| %>
<% @services.each do |service| %>
<li>
<%= check_box_tag 'service_ids[]', service.id ,:html =>{:'data-parsley-mincheck'=>3}%>
<%= h service.id %>
</li>
<% end %>
<%end%>
Generated HTML looks like this:
<input checked="checked" id="service_ids_" name="service_ids[]" type="checkbox" value="2" data-parsley-multiple="service_ids" data-parsley-id="7696">
<input checked="checked" id="service_ids_" name="service_ids[]" type="checkbox" value="3" data-parsley-multiple="service_ids" data-parsley-id="7696">
I have tried many other ways to set mincheck:
<%= check_box_tag 'service_ids[]', service.id ,:'data-parsley-mincheck'=>3%>
but still can't find working solution..
Any ideas ? Thanks,
Aucun commentaire:
Enregistrer un commentaire