# Formhelper & label produces incorrect output?

**URL:** <https://www.ruby-forum.com/t/formhelper-label-produces-incorrect-output/184182>\
**Category:** Rails\
**Created:** [February 26, 2010, 8:24am UTC](https://www.ruby-forum.com/t/formhelper-label-produces-incorrect-output/184182 "2010-02-26T08:24:56Z")\
**Posts on this page:** 2\
**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 26, 2010, 8:24am UTC](https://www.ruby-forum.com/t/formhelper-label-produces-incorrect-output/184182/1 "2010-02-26T08:24:56Z")

</div>

I’m looking at

\InstantRails-2.0-win\ruby\lib\ruby\gems\1.8\gems\actionpack-2.3.5\lib\action\_view\helpers\form\_helper.rb

at line 509. The comment reads:

```
  # label(:post, :title, "A short title")
  # # => <label for="post_title">A short title</label>

```

When I pass  
A short title  
through an HTML validator (e.g. [Validation Results - W3C Markup Validator](http://validator.w3.org/check) )… the  
message I get is

* * *

value of attribute “for” must be a single token

This attribute can not take a space-separated list of words as a value,  
but only one word (“token”). This may also be caused by the use of a  
space for the value of an attribute which does not permit it.

* * *

What I think the validator is looking for is this  
A short title  
instead of  
A short title

Am I interpreting this correctly?

---

<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 26, 2010, 5:22pm UTC](https://www.ruby-forum.com/t/formhelper-label-produces-incorrect-output/184182/2 "2010-02-26T17:22:06Z")

</div>

On Feb 26, 2:24 am, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> <label for="post_title">A short title</label>
> 
> ```
> 
> What I think the validator is looking for is this  
> A short title  
> instead of  
> A short title
> 
> Am I interpreting this correctly?

No, I think you’ve somehow confused the validator. I was able to get  
the error message you described, but only by changing the underscore  
to a space. The version without attributes is also very wrong if  
you’re using an XHMTML doctype.

–Matt J.
