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, 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, 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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
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