We Recommend

The Rails Way The Rails Way
Now, for the first time, there’s a comprehensive, authoritative guide to building production-quality software with Rails. Pioneering Rails developer Obie Fernandez and a team of experts illuminate the entire Rails API, along with the Ruby idioms, design approaches, libraries, and plug-ins that make Rails so valuable.


Posted By

bordalix on 06/20/07


Tagged

table checkbox columns


Versions (?)


checkbox with associated values checked in a 3 columns table


Published in: Rails 


  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 

You need to login to post a comment.