# config/initializers/formtastic.rb module FormtasticBootstrap class FormBuilder < Formtastic::FormBuilder # Allow "split-field" inputs such as name (first+last) or location (city+state). # Block contents are wrapped in a ".controls" field set next to the specified # +label+ # # Usage: # # <%= f.split_fields 'Name' do %> # <%= f.text_field :first_name, :placeholder => 'First', :style => 'width:80px' %> # <%= f.text_field :last_name, :placeholder => 'Last', :style => 'width:100px' %> # <% end %> # def split_fields(label, &block) if block_given? controls = template.capture(&block) label = template.content_tag :div, label, :class => 'control-label' controls = template.content_tag :div, controls, :class => 'controls' template.content_tag(:div, label + controls, :class => 'control-group') end end end end Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder