No commit activity in last 3 years
No release in over 3 years
Rails form builder for use with Twitter's Bootstrap library, with labels and inline errors.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 3.2.0.rc1
 Project Readme

BootstrapFormBuilder¶ ↑

A Rails form builder that outputs forms structured for use with the Twitter Bootstrap library. Labels are automatically created, and errors are displayed inline.

BootstrapFormBuilder is built using syntax specific to Ruby 1.9. It will not work on Ruby 1.8.

Usage¶ ↑

The builder conforms generally to the generic Rails form builder API.

<%= bootstrap_form_for @widget do |f| %>
  <%= f.text_field :name %>
  <%= f.collection_select :category_id, Category.all, :id, :name, include_blank: true %>
  <%= f.submit nil, class: 'primary' %>
<% end %>

Labels are automatically created for the field. The label and the input are wrapped inside of divs classed according to Twitter Bootstrap library’s conventions.

The field helpers also accept a block to which it yields the input or select tag. This can be used to decorate the input fields.

<%= f.text_field :price do |input_tag| %>
  <div class="input-append">
    <%= input_tag %>
    <label class="add-on">
      <%= f.check_box :taxable %>
      <span>Sales tax</span>
    </label>
  </div>
<% end %>

More information¶ ↑

twitter.github.com/bootstrap

TODO¶ ↑

  • Support label: false option to exclude label

  • Support inline placement of form helpers

  • Add new helper that calls #submit(nil, …)

  • Refactor tests to be less brittle (don’t use asset_match and regexps)

  • Get testing preamble setup for Trafis CI