Created
November 2, 2011 16:57
-
-
Save franciscoj/1334203 to your computer and use it in GitHub Desktop.
Use twitter bootstrap with simple_form
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
# config/initializer/simple_form.rb | |
SimpleForm.setup do |config| | |
config.hint_class = "hint input" | |
config.error_class = 'error input' | |
config.wrapper_class = :clearfix | |
config.wrapper_error_class = :error | |
end |
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
# config/initializer/simple_form_bootstrap.rb | |
SimpleForm::Inputs.constants.each do |klazz| | |
next if klazz == :Base | |
"SimpleForm::Inputs::#{klazz.to_s}".constantize.class_eval do | |
def input_with_surrounding_div | |
@builder.template.content_tag :div, input_without_surrounding_div, :class => "input" | |
end | |
alias_method_chain :input, :surrounding_div | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment