Skip to content Skip to sidebar Skip to footer

How To Create Horizontal Forms With Twitter Bootstrap And Rails Simple Form

I am trying to create horizontal forms with simple-form and bootstrap. I have already installed bootstrap using 'rails generate simple_form:install'. This is what i have in html.er

Solution 1:

simple_form is a really great gem for generating bootstrap forms. However, you have to do a little extra to get it working with Bootstrap’s form-horizontal class.

The README doesn’t mention this, but it’s built in. Just write your form declaration like this:

<%= simple_form_for [:admin, @c], html: { class: 'form-horizontal' },wrapper: :horizontal_formdo |f| %># ...form...

<% end %>

Note the wrapper attribute. This isn’t described in the README, and I had to dig through the code to figure it out.

Hope this helps you!

Post a Comment for "How To Create Horizontal Forms With Twitter Bootstrap And Rails Simple Form"