Created
January 8, 2010 11:34
-
-
Save beef/271999 to your computer and use it in GitHub Desktop.
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
# Place in /config/initializers | |
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
if html_tag =~ /<(input|textarea|select|label)[^>]+style=/ | |
style_attribute = html_tag =~ /class=['"]/ | |
html_tag.insert(style_attribute + 7, "fieldWithErrors ") | |
elsif html_tag =~ /<(input|textarea|select|label)/ | |
first_whitespace = html_tag =~ /\s/ | |
html_tag[first_whitespace] = ' class="fieldWithErrors" ' | |
end | |
html_tag | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment