Created
December 27, 2011 03:03
-
-
Save mgreenly/1522609 to your computer and use it in GitHub Desktop.
rails form formatting for twitter bootstrap #4
This file contains 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 characters
# ./app/helpers/boot_strap_form_builder.rb | |
class BootStrapFormBuilder < ActionView::Helpers::FormBuilder | |
def text_field(method, options={}) | |
t = @template | |
t.content_tag(:div, :class => "clearfix#{' error' unless @object.errors[method].blank?}") { | |
t.concat(t.label_tag method) | |
t.concat(t.content_tag(:div, :class => "input#{' error' unless @object.errors[method].blank?}") { | |
t.concat(super method) | |
if @object.errors[method].present? | |
t.concat(t.content_tag(:span, options[:help_text], :class => 'help-inline')) | |
end | |
}) | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment