-
-
Save JoshReedSchramm/7176154 to your computer and use it in GitHub Desktop.
<%= f.collection_check_boxes :venue_ids, Venue.all, :id, :name, checked: Venue.all.map(&:id) do |b| %> | |
<span> | |
<%= b.check_box %> | |
<%= b.label %> | |
</span> | |
<% end %> |
(http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/collection_check_boxes)
I can't understand why to use this code : "#{first_name.first}. #{last_name}"
And I tried this way, but it didn't work.
<%= builder.collection_check_boxes :questionnaire_surveys, :survey_id, Survey.all, :id, :name %>
I already posted my question here, could you please take a look and any suggestions will be greatly appreciated.
(http://stackoverflow.com/questions/31566905/not-sure-why-the-view-doest-work-rails-4-nested-attributes-and-has-many-throu)
Thanks . This helped me a lot. In my case i did a little modification
<%= f.collection_check_boxes :venue_ids, Venue.all, :id, :name, checked: JSON.parse(@method.venue_ids) %>
This way i was able to return the checked values
Hello,
Is there a way to add "Other" options with collection checkboxes? On selection of this "Other" checkbox, i need to enter a value from textbox and add it in my database.
a little hacky way of achieving this:
<% primary_options = my_options.collect do |option| %>
<% [option,option] %>
<% end %>
<%= p.collection_check_boxes :my_options, primary_options, :first, :last do |option| %>
<%= option.check_box + option.text %>
<% if option.text == 'Other' %>
<input type='text' id='other-input' class='other-textbox' value="option_group_other">
<% end %>
<% end %>
Thanks for this. Was looking through the official documentation with no avail.