Danny
Danny

Reputation: 6025

How to add a custom class to simple_form f.association as: :radio_buttons

I'm using a simple_form with a

f.association as: :radio_buttons

This generates a html structure like

div.control-group
  label.control-label
  div.controls
    label.radio
    input[type="checkbox"]

I can add specific custom classes to the control-label and to the input field, using label_html = ... or input_html = ...

I however would like to add a specific class to the label.radio

Is there any way I can achieve this?

Upvotes: 1

Views: 2426

Answers (1)

nickcen
nickcen

Reputation: 1692

use item_wrapper_class

= simple_form_for @post do |f|
  = f.input :name
  = f.association :comments, :as => :radio_buttons, :item_wrapper_class => 'test_class'

Upvotes: 2

Related Questions