# Hooking validates

**URL:** <https://www.ruby-forum.com/t/hooking-validates/183761>\
**Category:** Rails\
**Created:** [February 19, 2010, 5:14pm UTC](https://www.ruby-forum.com/t/hooking-validates/183761 "2010-02-19T17:14:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [February 19, 2010, 5:14pm UTC](https://www.ruby-forum.com/t/hooking-validates/183761/1 "2010-02-19T17:14:46Z")

</div>

I want to hook the validation routines so that I can flag html labels  
and change their color to better indicate which fields need to be  
corrected in a form.

Is there a way to do this conveniently and/or conventionally?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [February 19, 2010, 5:18pm UTC](https://www.ruby-forum.com/t/hooking-validates/183761/2 "2010-02-19T17:18:47Z")

</div>

On Feb 19, 4:14 pm, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to hook the validation routines so that I can flag html labels  
> and change their color to better indicate which fields need to be  
> corrected in a form.
> 
> Is there a way to do this conveniently and/or conventionally?

Have a look at field\_error\_proc

Fred

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [February 19, 2010, 5:36pm UTC](https://www.ruby-forum.com/t/hooking-validates/183761/3 "2010-02-19T17:36:56Z")

</div>

On 19 February 2010 16:14, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to hook the validation routines so that I can flag html labels  
> and change their color to better indicate which fields need to be  
> corrected in a form.
> 
> Is there a way to do this conveniently and/or conventionally?

you can interrogate the model errors to see what fields are invalid,  
but it’s easier to use a plugin that someone else has already done the  
same thing in. I’ve recently used Formtastic to generate forms and the  
resultant helpful, highlighted errors.

> **[GitHub - formtastic/formtastic: A Rails form builder plugin with semantically...](https://github.com/formtastic/formtastic)**
>
> A Rails form builder plugin with semantically rich and accessible markup. - GitHub - formtastic/formtastic: A Rails form builder plugin with semantically rich and accessible markup.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [February 19, 2010, 5:56pm UTC](https://www.ruby-forum.com/t/hooking-validates/183761/4 "2010-02-19T17:56:54Z")

</div>

Michael P. wrote:

> On 19 February 2010 16:14, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I want to hook the validation routines so that I can flag html labels  
> > and change their color to better indicate which fields need to be  
> > corrected in a form.
> > 
> > Is there a way to do this conveniently and/or conventionally?
> 
> you can interrogate the model errors to see what fields are invalid,  
> but it’s easier to use a plugin that someone else has already done the  
> same thing in. I’ve recently used Formtastic to generate forms and the  
> resultant helpful, highlighted errors.  
> [GitHub - formtastic/formtastic: A Rails form builder plugin with semantically rich and accessible markup.](http://github.com/justinfrench/formtastic)

Thanks, Michael.

I have tried formtastic and have found it more of a hassle than a help.

Maybe I’m just not seeing the benefits.

* * *

Thanks, Frederick, I’ll look at field\_error\_proc.
