Use None (Option) or Empty (Box) as the value of the attribute -- this  
will cause the pairToUnprefixed implicit that is being used inside  
SHtml to not generate an attribute.

e.g.:

val disableAttr: Box[String] = if (disableAll) Full("disabled") else  
Empty

bind("person", xhtml,
      ...
      "firstName" -> SHtml.text(person.firstName, person.firstName =  
_, "id" -> "firstName", "disabled" -> disableAttr),
      ...)

-Ross


On Nov 9, 2009, at 6:51 PM, Jim Barrows wrote:

> I found this answer on nabble but it's regarding setting the values  
> client side.  I want to set them in the snippet, depending on data.
> This doesn't work, but will give you a better idea of what I'm  
> trying to do:
>  def bindPerson(xhtml: NodeSeq, action: () => Unit,  
> submitButtonName: String, disableAll: boolean): NodeSeq = {
>     // Hold a val here so that the "id" closure holds it when we re- 
> enter this method
>     val currentId = person.id
>     val disableString :String = disableAll match {
>       case true => "disabled"
>       case false => ""
>     }
>     bind("person", xhtml,
>       "id" -> SHtml.hidden(() => person.id = currentId),
>       //      "version" -> SHtml.hidden(() => person.version),
>       "firstName" -> SHtml.text(person.firstName, person.firstName =  
> _, "id" -> "firstName", "disabled" -> disableString),
>       "middleName" -> SHtml.text(person.middleName,  
> person.middleName = _, "id" -> "middleName", "disabled" ->  
> disableString),
>       "lastName" -> SHtml.text(person.lastName, person.lastName = _,  
> "id" -> "lastName", "disabled" -> disableString),
>       "submit" -> SHtml.submit(?(submitButtonName), action))
>   }
>
> -- 
> James A Barrows
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to