Permalink
Browse files

Include option attributes in multiSelect_*

  • Loading branch information...
1 parent 5f0011a commit 45c16425b10fefe015b00c2738cf3f459d4d972a @melgar melgar committed with Jun 9, 2014
Showing with 11 additions and 12 deletions.
  1. +1 −1 build.sbt
  2. +10 −11 web/webkit/src/main/scala/net/liftweb/http/SHtml.scala
View
@@ -2,7 +2,7 @@ import Dependencies._
organization in ThisBuild := "net.liftweb"
-version in ThisBuild := "2.6-ccap08"
+version in ThisBuild := "2.6-ccap09"
homepage in ThisBuild := Some(url("http://www.liftweb.net"))
@@ -1000,8 +1000,7 @@ trait SHtml {
fmapFunc((testFunc)) { funcName =>
(attrs.foldLeft(<select>{opts.flatMap {
case option =>
- option.attrs.foldLeft(<option value={option.value}>{option.label}</option>)(_ % _) %
- selected(deflt.exists(_ == option.value))
+ optionToElem(option) % selected(deflt.exists(_ == option.value))
}}</select>)(_ % _)) %
("onchange" -> (jsFunc match {
case Full(f) => JsCrVar(key, JsRaw("this")) & deferCall(raw(funcName, key), f)
@@ -1821,6 +1820,10 @@ trait SHtml {
}
}
+ private def optionToElem(option: SelectableOption[String]): Elem =
+ option.attrs.foldLeft(<option value={option.value}>{option.label}</option>)(_ % _)
+
+
private final case class SelectableOptionWithNonce[+T](value: T, nonce: String, label: String, attrs: ElemAttr*)
/**
@@ -1905,8 +1908,7 @@ trait SHtml {
attrs.foldLeft(fmapFunc(testFunc) { fn =>
<select name={fn}>{opts.flatMap {
case option =>
- option.attrs.foldLeft(<option value={option.value}>{option.label}</option>)(_ % _) %
- selected(deflt.exists(_ == option.value))
+ optionToElem(option) % selected(deflt.exists(_ == option.value))
}}</select>
})(_ % _)
}
@@ -1938,8 +1940,7 @@ trait SHtml {
fmapFunc(func) { funcName =>
attrs.foldLeft(<select name={funcName}>{opts.flatMap {
case option =>
- option.attrs.foldLeft(<option value={option.value}>{option.label}</option>)(_ % _) %
- selected(deflt.exists(_ == option.value))
+ optionToElem(option) % selected(deflt.exists(_ == option.value))
}}</select>)(_ % _)
}
@@ -1973,8 +1974,7 @@ trait SHtml {
List(
attrs.foldLeft(<select multiple="true" name={funcName}>{opts.flatMap {
case option =>
- option.attrs.foldLeft(<option value={option.value}>{option.label}</option>)(_ % _) %
- selected(deflt.contains(option.value))
+ optionToElem(option) % selected(deflt.contains(option.value))
}}</select>)(_ % _),
<input type="hidden" value={hiddenId} name={funcName}/>
)
@@ -2044,8 +2044,7 @@ trait SHtml {
funcName =>
(attrs.foldLeft(<select>{ opts.flatMap {
case option =>
- option.attrs.foldLeft(<option value={ option.value }>{ option.label }</option>)(_ % _) %
- selected(deflt.exists(_ == option.value))
+ optionToElem(option) % selected(deflt.exists(_ == option.value))
} }</select>)(_ % _)) %
("onchange" -> (jsFunc match {
case Full(f) => JsCrVar(key, JsRaw("this")) & deferCall(raw(funcName, key), f)
@@ -2119,7 +2118,7 @@ trait SHtml {
deflt: Seq[String],
func: AFuncHolder, attrs: ElemAttr*): Elem =
fmapFunc(func)(funcName =>
- attrs.foldLeft(<select multiple="true" name={funcName}>{opts.flatMap(o => (<option value={o.value}>{o.label}</option>) % selected(deflt.contains(o.value)))}</select>)(_ % _))
+ attrs.foldLeft(<select multiple="true" name={funcName}>{opts.flatMap(o => optionToElem(o) % selected(deflt.contains(o.value)))}</select>)(_ % _))
def textarea(value: String, func: String => Any, attrs: ElemAttr*): Elem =

0 comments on commit 45c1642

Please sign in to comment.