On Mon, Nov 17, 2008 at 3:41 PM, Charles F. Munat <[EMAIL PROTECTED]> wrote:
> > Added: > > > http://liftweb.net/index.php/FAQ#How_do_I_add_attributes_to_form_fields_created_with_SHtml_methods.3F > Awesome! Thanks! > > Chas. > > Jorge Ortiz wrote: > > Oops, it might be: > > > > SHtml.text(user.name <http://user.name>, user.name <http://user.name> = > _) % > > ("size" -> "24") % > > ("maxlength" -> "48") % > > ("id" -> "user_name") % > > ("title" -> "Enter your name") > > > > One or both of those should work. > > > > --j > > > > On Mon, Nov 17, 2008 at 12:27 PM, Jorge Ortiz <[EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]>> wrote: > > > > Try: > > > > SHtml.text(user.name <http://user.name>, user.name > > <http://user.name> = _) % > > ("size", "24") % > > ("maxlength", "48") % > > ("id", "user_name") % > > ("title", "Enter your name") > > > > That should work. > > > > --j > > > > On Mon, Nov 17, 2008 at 12:21 PM, Charles F. Munat <[EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]>> wrote: > > > > > > I spend a lot of time writing % new UnprefixedAttribute(...) to > add > > attributes to SHtml form elements (input, textarea, select, > etc.). > > > > It would be nice if the relevant SHtml methods would permit > optional > > extra parameters in the form of tuples where contents are > name-value > > pairs that get translated to attributes. I don't think this > > would be a > > breaking change. > > > > In other words, instead of: > > > > SHtml.text(user.name <http://user.name>, user.name > > <http://user.name> = _) % > > new UnprefixedAttribute("size", "24", > > new UnprefixedAttribute("maxlength", "48", > > new UnprefixedAttribute("id", "user_name", > > new UnprefixedAttribute("title", "Enter your name", Null) > > ) > > ) > > ) > > > > I could do: > > > > SHtml.text(user.name <http://user.name>, user.name > > <http://user.name> = _, > > ("size", "24"), > > ("maxlength", "48"), > > ("id", "user_name"), > > ("title", "Enter your name") > > ) > > > > Which is a hell of a lot cleaner and faster, and I don't have to > > import > > UnprefixedAttribute and remember the % and the new keywords. > > > > Or is this already possible and I'm missing it? > > > > I have an online survey with 43 questions on 5 pages involving > > more than > > 150 database fields. The snippet is already over 700 lines and > > growing. > > It's just unmanageable. > > > > Another thing: the <label> element is a very important part of > > accessibility to persons with disabilities, but it needs a "for" > > attribute that references the "id" attribute of the input > > element (or > > textarea, etc.). The current SHtml output (unlike Rails) does not > > generate an id attribute, so they have to be added by hand. Has > > anyone > > given any thought to automatically-generated id elements on form > > fields? > > Better yet, some way to integrate labels? > > > > Ideally, I would do something like this: > > > > <survey:name label="Your name"/> > > > > Or this: > > > > <survey:name>Your name</survey:name> > > > > and bind would allow me to generate this: > > > > <label for="id123">Your name > > <input type="text" id="id123" value="" > > name="F1226951216428645000_I0G"/> > > </label> > > > > What do others think? Is this already possible? > > > > Chas. > > > > > > > > > > > > > > > > > -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
