Derek J
Derek J

Reputation: 807

Rails/Formtastic many-to-many ordered list HTML

I have a Post model with a many-to-many Category association. In my Post form, I call f.input :categories, :as => :check_boxes and get a nice ordered list of check boxes. Is there anyway to add a class to each <li> using the category's name (or any Category data)?

Example:

<li class="<%= category.name %>">...label and input...</li>
<li class="<%= category.name %>">...label and input...</li>
<li class="<%= category.name %>">...label and input...</li>

Thanks!

Upvotes: 0

Views: 430

Answers (1)

eugen
eugen

Reputation: 9226

Try something like

f.input :categories, :as => :check_boxes, :value_as_class => true

Upvotes: 1

Related Questions