rAzOr
rAzOr

Reputation: 320

Customising collection_check_boxes

<%= f.collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b| %>
   <% b.label { b.check_box + b.text } %>
<% end %>

The above code outputs the html as

<label tag>
    <input checkbox tag></checkbox>
    value of b.text
</label>

Can it be modified to output the html(i.e label tag after input tag) as

<input checkboxtag></checkbox>
<labeltag>
    value of b.text
</labeltag>

Tried various combinations with collection_check_boxes but couldn't succeed.

Upvotes: 0

Views: 95

Answers (1)

max
max

Reputation: 102036

<%= f.collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b| %>
   <%= b.check_box %>
   <%= b.label %>
<% end %>

Upvotes: 1

Related Questions