Skip to content

Instantly share code, notes, and snippets.

@rodrigopinto
Created July 17, 2010 23:59
Show Gist options
  • Save rodrigopinto/479961 to your computer and use it in GitHub Desktop.
Save rodrigopinto/479961 to your computer and use it in GitHub Desktop.
#...
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