Nest input inside f.label ( rails form generation )

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-03-16T18:46:31Z Indexed on 2010/03/16 18:51 UTC
Read the original article Hit count: 246

Filed under:
|
|
|

I want to use the f.label method to create my form element labels, however - i want to have the form element nested inside the label. Is this possible?

-- From W3C --

To associate a label with another control implicitly, the control element must be within the contents of the LABEL element. In this case, the LABEL may only contain one control element. The label itself may be positioned before or after the associated control.

In this example, we implicitly associate two labels with two text input controls:

<FORM action="..." method="post">
<P>
<LABEL>
   First Name
   <INPUT type="text" name="firstname">
</LABEL>
<LABEL>
   <INPUT type="text" name="lastname">
   Last Name
</LABEL>
</P>
</FORM>

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about form