Created
July 17, 2010 23:59
-
-
Save rodrigopinto/479961 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
#... | |
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
if html_tag =~ /<label/ | |
%|#{html_tag} <font class="error">#{[instance.error_message].join(', ')}</font>| | |
else | |
error_class = 'fieldWithErrors' | |
nodes = Hpricot(html_tag) | |
nodes.each_child do |node| | |
unless !node.elem? || node[:type] == 'hidden' || node.classes.include?(error_class) | |
node[:class] = node.classes.push(error_class).join(' ') | |
end | |
end | |
nodes.to_html | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment