Forum: Ruby on Rails RE: Re: label tag with errors?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B29105598b6464efc13b04cb445efa85?d=identicon&s=25 Chris Bruce (Guest)
on 2006-05-09 01:57
(Received via mailing list)
Paul,

You can do this by creating a custom form builder.  Do some research on
that.  Here is a place to start:

http://rails.techno-weenie.net/question/2006/4/28/...




Chris

________________________________________
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Paul Barry
Sent: Monday, May 08, 2006 12:50 PM
To: rails@lists.rubyonrails.org
Subject: [Rails] Re: label tag with errors?

any advice on this?  a lable tag that has a different class if the
property has errors...
On 5/7/06, Paul Barry < mail@paulbarry.com> wrote:
I'd like to create a label tag that has a special css class if has
errors.  So Ideally, I'd like:

<%= label('object','property','Property') %>

To generate:

<label for="object_property">Property</label>

And if there are errors on object.property, generate this:

<label for="object_property" class="fieldWithErrors">Property</label>

First of all, is there an easy way to do this?

I'm assuming there isn't, so I thought it shouldn't be too hard to
create my own helped to do this, but after taking a look at the source
for the other tags (text_field, check_box, etc.), it's not clear how to
do it.  Any ideas?
This topic is locked and can not be replied to.