# Eliminating .fieldWithErrors for labels

**URL:** <https://www.ruby-forum.com/t/eliminating-fieldwitherrors-for-labels/184515>\
**Category:** Rails\
**Created:** [March 3, 2010, 7:17pm UTC](https://www.ruby-forum.com/t/eliminating-fieldwitherrors-for-labels/184515 "2010-03-03T19:17:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlwinter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecccb3/32.png) [@rlwinter](https://www.ruby-forum.com/u/rlwinter)\
**Post date:** [March 3, 2010, 7:17pm UTC](https://www.ruby-forum.com/t/eliminating-fieldwitherrors-for-labels/184515/1 "2010-03-03T19:17:18Z")

</div>

I would like to prevent Rails from wrapping my label tags inside the  
fieldWithErrors div.

I found a way to do it, but was hoping that there’s a better solution.

Here’s and example from a git diff that shows what I’ve done:

\<% form\_for(venue) do |f| %\>

- \<%= f.label :name %\>  
- \<%= f.text\_field :name %\> + +

\<%= label\_tag "venue\_name", "Name" %\>
+ 
\<%= f.text\_field :name %\>

This actually does work. Apparently f.label helper does the wrapping of  
the errors div, where label\_tag does not. However, using label\_tag  
doesn’t know about the venue object scope so I have to specify that  
explicitly, as you can see above.

Also notice that I wrapped both the label and text fields inside their  
own divs as well. This was to prevent invalid HTML when Rails wraps the  
elements inside

 tags when there are errors  
on the form.

Is this the the best approach, or is there a better way to get f.label  
helper to stop wrapping the labels?

The reason I want this is because I like the standard scaffolding style  
of wrapping the fields with a red border, but this is also causing my  
labels to have an ugly red background.

I know I could just use normal text and not labels, but I also like the  
behavior of true HTML form labels.

Any suggestions would be welcome.
