The "for" attribute in the <label> element points at the <input> 
element's *id*, not it's name. Also, where is the label? You've got an 
element, but no label (unless I'm still asleep).

http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1

So this is actually quite easy:

bind("login", xhtml,
   "username" -> <label for="username">Username {SHtml.text(username,
     username = _, ("id", "username"))}</label>,
   ...

That names for the inputs are generated doesn't matter because the for 
attribute refers to the id, not the name.

You could, of course, use David's method but add something that sets the 
id attribute = the name attribute since the name is going to be unique 
on the page.

Chas.

João Pereira wrote:
> it's looks great and works great too. :)
> 
> thank you
> 
> On Mon, Apr 13, 2009 at 5:18 PM, David Pollak 
> <[email protected] <mailto:[email protected]>> 
> wrote:
> 
>     def label(in: Elem): NodeSeq = <label for={in \ "@name"} /> ++ in
> 
>     bind("login", xhtml,
>             "username" -> label(SHtml.text(username, username(_)))
> 
>     How does that look?
> 
>     2009/4/13 João Pereira <[email protected]
>     <mailto:[email protected]>>
> 
>         Hello,
> 
>         I have the following snippet:
> 
>         HTML:
> 
>             <div id="login"><lift:login.login form="post">
>                 <login:username />
>                 <login:password />
>                 <login:submit />
>             </lift:login.login></div>
> 
>         Scala:
> 
>         bind("login", xhtml,
>                  "username"->SHtml.text(username,username(_)),
>                  "password"->SHtml.text(password, password(_)),
>                  "submit" ->SHtml.submit("login", authenticate))
> 
> 
>         Rendered HTML is:
> 
>         <div id="login"><form method="post" action="/login">
>         <input name="F1177922287215MUE" type="text" value="zxczxc" />
>         <input name="F1177922287216DXQ" type="text" value="zxcczx" />
>         <input name="F1177922287217EXX" type="submit" value="login" />
>         </form></div>
> 
> 
>         What is the best strategy to have a <label for="..."> HTML tag
>         rendered for each input field?
> 
>         The desired output will be:
> 
>         <div id="login"><form method="post" action="/login">
>         *<label for="F1177922287215MUE"/>*
>         <input name="F1177922287215MUE" type="text" value="zxczxc" />
>         *<label for="F1177922287216DXQ"/>*
>         <input name="F1177922287216DXQ" type="text" value="zxcczx" />
>         <input name="F1177922287217EXX" type="submit" value="login" />
>         </form></div>
> 
> 
>         thanks
>         --
>         João Miguel Pereira, PMP
>         http://jpereira.eu
>         http://www.linkedin.com/in/joaomiguelpereira
>         [email protected] <mailto:[email protected]>
>         (351) 96 275 68 58
> 
> 
> 
> 
> 
>     -- 
>     Lift, the simply functional web framework http://liftweb.net
>     Beginning Scala http://www.apress.com/book/view/1430219890
>     Follow me: http://twitter.com/dpp
>     Git some: http://github.com/dpp
> 
> 
> 
> 
> 
> -- 
> João Miguel Pereira, PMP
> http://jpereira.eu
> http://www.linkedin.com/in/joaomiguelpereira
> [email protected] <mailto:[email protected]>
> (351) 96 275 68 58
> 
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to