Created
July 28, 2013 19:08
Revisions
-
eraserewind created this gist
Jul 28, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ class BootstrapHorizontalForm < ActionView::Helpers::FormBuilder def text_field(method, options={}) width = options[:width] || 10 t = @template t.content_tag(:div, :class => "form-group#{' has-error' unless @object.errors[method].blank?}") { t.concat(t.label(@object_name, method, class: 'col-lg-2 control-label')) t.concat(t.content_tag(:div, class: "col-lg-#{width}") { t.concat(t.text_field(@object_name, method, options.merge(class: 'form-control'))) if @object.errors[method].present? t.concat(t.content_tag(:span, @object.errors[method].join(', '), :class => 'help-block')) end }) } end def check_box(method, options={}) t = @template t.content_tag(:div, class: "form-group #{' has-error' unless @object.errors[method].blank?}") { t.concat(t.content_tag(:div, class: 'col-lg-10 col-offset-2') { t.concat(t.content_tag(:div, class: 'checkbox') { t.concat(t.check_box(@object_name, method)) t.concat(t.label(@object_name, method)) }) }) } end def submit(value=nil, options={}) @template.content_tag(:div, class: 'col-lg-10 col-offset-2') { super(value, options.merge(class: 'btn btn-primary')) } end end