Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Using simple_form and integrating Twitter Bootstrap

Tags:

I'm trying to build a rails app and simple_form looks to be a really useful gem. Problem is that I am using twitter bootstrap css to do the styling and the simple_form doesn't allow you to specify the layout of the html.

Can anyone tell me how I can conform the simple_form html into the format bootstrap css wants?

like image 931
devinross Avatar asked Aug 25 '11 22:08

devinross


2 Answers

Note: This answer only applies to SimpleForm < 2.0

Start with this in config/initializers/simple_form.rb:

SimpleForm.form_class = nil SimpleForm.wrapper_class = 'clearfix' SimpleForm.wrapper_error_class = 'error' SimpleForm.error_class = 'help-inline' 

Then there's space missing between the label element and the input, which you can add with this:

label {   margin-right: 20px; } 

There's probably more, but it's a start.

like image 101
robinst Avatar answered Sep 29 '22 07:09

robinst


Simple form 2.0 is bootstrap-aware:

rails generate simple_form:install --bootstrap 
like image 27
clyfe Avatar answered Sep 29 '22 06:09

clyfe