The standard Rails validation wraps my error-filled fields in a div
of class fieldWithErrors
.
How can I change it so that the erroneous element's parent gets assigned that class instead of having a new div
created on the page?
EDIT:
Per this website, this wraps errors in span
s instead of div
s, which helps my formatting a little, but I'd really love to just stick the error class in the parent element...
app/config/environment.rb
(in the initializer block):
config.action_view.field_error_proc = Proc.new { |html_tag, instance| %(<span class="fieldWithErrors">#{html_tag}</span>) }
The Hpricot method listed on that site looks like what I want, but I don't know where I should be putting it. I also keep getting uninitialized constant ActionView
errors too. Can someone help?