Hey guys,

If you have a call like:

<lift:mysnippet form="post"> is translated to <form method="post"
action="blah">

however, is there a way to set the id attribute on that node? Simply
adding the id in the markup is removed by lifts processing, so thats
no good as most javascript / css things either need id or class to
select the appropriate element.

As im on a tight timeline with something, I just hacked the code to
make it work with the id attribute (i know thats bad!) - we need a
better solution really, and one that can accommodate any custom user
attributes. Currently, the lift head looks like:

    def checkAttr(attr_name: String, in: MetaData): MetaData =
    in.filter(_.key == attr_name).toList match {
      case Nil => Null
      case x => new UnprefixedAttribute(attr_name,
Text(x.first.value.text), Null)
    }

    attrs.get("form").map(ft => (
        (<form action={S.uri} method={ft.text}>{ret}</form> %
         checkMultiPart(attrs)) %
        checkAttr("class", attrs)) % checkAttr("id",attrs) ) getOrElse
ret


    attrs.get("form").map(ft => <form action={S.uri}
method={ft.text}>{ret}</form> % checkMultiPart(attrs)) getOrElse ret
  }

    def checkMultiPart(in: MetaData): MetaData = in.filter(_.key ==
"multipart").toList match {
      case Nil => Null
      case x => new UnprefixedAttribute("enctype", Text("multipart/
form-data"), Null)
    }

As im not familiar with the MetaData class, I wasn't sure how best to
alter this. It seems we have 3 cases: unprefixed attributes, prefixed
attributes and null. Perhaps some kind of flatmap/map or something to
itterate through the attributes and return the appropriate object.

Anyway, i must dash - cheers guys

Tim


--~--~---------~--~----~------------~-------~--~----~
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