Rails 3: Change validation error formatting?

Hello, I've been reading that Rails 3 offers a bunch of new validation features.

Is there a way to customize the validation error formatting? For example, I prefer to style the elements surrounding a form input containing an error, not just the input itself.

Also, I might like to define my own class names for styling these elements, for example if they don't conform to my naming standards.

Is this easier in Rails 3 than in 2?

I found a few articles about new validation functionality, but they seem to be formatting the old way.


Since I have no experience Rails 2, I can't compare the two. However, it's pretty easy with Rails 3. You can override the default behavior like so:

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|   *** YOUR CODE HERE *** end

The README that comes with the ActionPack gem has a more verbose explanation about this. (I just wish there was a way to tell it to add some kind of styling if a field validated properly!)

Hello, thanks for your response.

I'm looking at actionpack-3.0.0.beta3/README and can't find any mention of this.

Using the example below, is there a way to style the elements surrounding the invalid input (and not just the input itself)?

I'd like to change the CSS class name, too. Basically I'd like to customize validation without adding a ton of overhead to the framework's existing procedures.