checkbox with associated values checked in a 3 columns table


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <p>Companies:<br/>
  2. <table class="tbl">
  3. <% cells = 0 %>
  4. <% Company.find(:all).each do |c| %>
  5. <% cells += 1 %>
  6. <% if cells.divmod(3)[1] == 1 -%><tr><% end -%>
  7. <td><input type="checkbox" name="technology[company_ids][]" value="<%= c.id -%>"
  8. <% if @technology.companies.include?(c) -%> checked="checked" <% end -%> />
  9. <%= c.name %></td>
  10. <% if cells.divmod(3)[1] == 0 -%></tr><% end -%>
  11. <% end %>
  12. </table>
  13. </p>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.