plataformatec/simple_form — Issue #452: Styling the labels for a check box collection
Author: noctivityinc
Created: 2012-02-13 20:29:10+00:00
State: open

I have a simple HABTM relationship between categories and fonts. A category can have many fonts. Anyway, in my form I want to display a list of all the fonts with a checkbox next to each of them so I can select the fonts for a category.

The catch is that I want to add the font class to the LABEL for each option so that it is applied. In this case, the class is an attribute called *class_name* inside of the font model.

I have this:

= f.association :fonts

and have tried lots of things, including:

= f.association :fonts, :collection => Font.all.map { |o| [o.name, o.id, { :class => "#{o.class_name}" }] }, :as => :check_boxes

without luck. How can I accomplish this?