Brand new to Rails. How do I add a <li>
wrapper to each checkbox / label element generated by the following code?
<%= f.collection_check_boxes :publish_to, [['YouTube'], ['Hulu'], ['Roku'], ['Owned Website'], ['Other']], :first, :first %>
The final outputted HTML would look like:
<li class="checkbox-wrap">
<label></label>
<input type="checkbox"/>
</li>
Thanks in advance!
It's possible. collection_check_boxes
allows you to do it like this:
<ul>
<%= f.collection_check_boxes :publish_to, [['YouTube'], ['Hulu'], ['Roku'], ['Owned Website'], ['Other']], :first, :first do |b| %>
<li>
<%= b.label %>
<%= b.check_box %>
</li>
<% end %>
</ul>
Works on Rails 5 as well.
Reference: https://apidock.com/rails/v4.2.1/ActionView/Helpers/FormOptionsHelper/collection_check_boxes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With