ricsrock
ricsrock

Reputation: 971

Inline checkboxes with simple_form association?

I'd like to render each checkbox and label as a pair inline with the next checkbox-and-label pair on the next line.

I'm using simple_form's association method:

f.association :positions, as: :check_boxes

Is there a way to insert a tag - maybe a div - for each input-label pair? ...that can then be styled?

Upvotes: 3

Views: 3958

Answers (1)

jugglinghobo
jugglinghobo

Reputation: 419

Just to help other people that stumble over this:

simple_form's associations helper accepts item_wrapper_tag and item_wrapper_class options.

In your case, this could probably work:

f.association :positions, as: :check_boxes, item_wrapper_tag: :div, item_wrapper_class: "style_item"

sources: http://rubydoc.info/github/plataformatec/simple_form/master/SimpleForm/FormBuilder:collection_check_boxes

how to change class of a label for checkboxes in simple_form

Upvotes: 4

Related Questions