If you are using Simple Form and Bootstrap 3, you probably initialized your app with something similar to:
rails generate simple_form:install --bootstrap
which adds a file called simple_form_bootstrap.rb to your application with many customizations that make Simple Form output nicely formatted Bootstrap 3 forms.
For Call to Buzz, an app I’m building, I had several booleans to display, like this:
My problem was that I wanted a label to explain what those booleans are, something like this:
I achieved that by creating a wrapper that’s a mix between :horizontal_boolean and horizontal_radio_and_checkboxes which I called horizontal_boolean_with_label and looks like this:
config.wrappers :horizontal_boolean_with_label, tag: "div", class: "form-group", error_class: "has-error" do |b| b.use :html5 b.optional :readonly b.use :label, class: "col-sm-3 control-label" b.wrapper tag: "div", class: "col-sm-9" do |wr| wr.wrapper tag: "div", class: "checkbox" do |ba| ba.use :label_input end wr.use :error, wrap_with: {tag: "span", class: "help-block"} wr.use :hint, wrap_with: {tag: "p", class: "help-block"} end end
Leave a Reply