(no subject)

i love how rails adds code around the fields when they have errors,
but what if i want to add a css class to another element in the form
when there is an error, say the form label or something like that.

i looked around at the api for validations and it looked like you can
check individual methods for errors. i would imagine you can do that
for the fields you have validations for and write some sort of
conditional that would put a class or any other html you want in
there, but i’m not quite sure how to implement that. does anyone have
any examples? is there a better way of doing something like that?

On 11/14/06, Josh K. [email protected] wrote:

any examples? is there a better way of doing something like that?

Assuming a simple form creating a user AR model:

<% if @user.errors[:username] -%>

<% end -%>

Hope this helps.


Zack C.
http://depixelate.com