Skip to content

Instantly share code, notes, and snippets.

@beef
Created January 8, 2010 11:34
Show Gist options
  • Save beef/271999 to your computer and use it in GitHub Desktop.
Save beef/271999 to your computer and use it in GitHub Desktop.
# 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