Bootstrap2FormBuilder
Supports Bootstrap 2
This gem adds a helper to all of your views called bootstrap_form_for, which generates a form for a given model object
and fields with HTML and CSS markup that works with the Twitter bootstrap
library.
Install
Add to your gemfile:
ruby
gem "bootstrap2_form_builder"
After bundling the gem run
console
rails g bootstrap2_form_builder:install
This will create a partial called error_messages that will contain formatted errors on the object the form is for. This generator also takes an option to use HAML (it uses erb by default):
console
rails g bootstrap2_form_builder:install -t haml
Usage
Lets say you have a Person model with required attributes name and email, and an optional attribute of website. In your persons_controller in the new action you would set a variable @person = Person.new, which would be handed off to your view.
In your view, call bootstrap_form_for just like you would a regular form_for, except leave out labels and most other typical markup.
For exmaple:
ruby
<%= bootstrap_form_for @person do |form| %>
<%= form.text_field :name %>
<%= form.text_field :email %>
<%= form.text_field :website %>
<% end %>
This will generate HTML like this:
```html