Created
December 8, 2011 18:45
-
-
Save er1c/1448001 to your computer and use it in GitHub Desktop.
extra_html monkey patch for formtastic-bootstrap
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
module FormtasticBootstrap | |
module Inputs | |
module Base | |
module Html | |
def extra_html | |
template.content_tag(:div, Formtastic::Util.html_safe(extra_html_text),:class => (options[:extra_html_class] || 'extra-html')) if extra_html? | |
end | |
def extra_html? | |
extra_html_text.present? && !extra_html_text.kind_of?(Hash) | |
end | |
def extra_html_text | |
localized_string(method, options[:extra_html], :extra_html) | |
end | |
def extra_html_position | |
options[:extra_html_position] ||= 1 | |
end | |
end | |
module Wrapping | |
def input_div_wrapping(inline_or_block_errors = :inline) | |
template.content_tag(:div, :class => "input") do | |
tag_content = [yield, error_html(inline_or_block_errors), hint_html(inline_or_block_errors)] | |
tag_content.insert(extra_html_position,extra_html) | |
tag_content.join("\n").html_safe | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment