How do you display form field highlighting for fields that fail validation errors in Rails 3.1? I know that scaffolding automatically generates the css and controller code to handle this, but I was wondering if there was a way to generate that manually. I have already implemented the string display of error messages through: @user.errors.full_messages.each…etc, but I can’t get the fields to become highlighted in red. Any ideas?
Thanks.
Assuming you have an error class for fields in your CSS file:
Is this what you want?
Extra: here’s a section about customizing default ActiveRecord validations CSS.
Edit: (about extra ifs)
And then:
(I may have make a mistake in there – I’m writing on a phone – but you get the general idea. You can code this in number of ways = infinity, so do it the way you like…)