本文整理汇总了Scala中views.html.helper.FieldConstructor类的典型用法代码示例。如果您正苦于以下问题:Scala FieldConstructor类的具体用法?Scala FieldConstructor怎么用?Scala FieldConstructor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FieldConstructor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: password
//设置package包名称以及导入依赖的类
package views.html.htmlForm
import play.api.data.Field
import play.api.i18n.Lang
import play.twirl.api.Html
import views.html.helper.FieldConstructor
object password {
def apply(field: Field, label: String, args: (Symbol, Any)*)
(implicit handler: FieldConstructor, lang: Lang): Html =
Html {
val label2 = if (label.endsWith("*")) s"${ label.substring(0, label.length-1) }<sup>*</sup>" else label
s"""<dl ${ if (field.errors.nonEmpty) "class='error'" else "" } id="${ field.id }_label">
| <dt><label for="${ field.id }">$label2</label></dt>
| <dd><input type="password" id="${ field.id }" name="${ field.id }" value="${ field.value }">
| ${ if (field.errors.nonEmpty) field.errors else "" }</dd>
|</dl>
|""".stripMargin
}
}
示例2: Utils
//设置package包名称以及导入依赖的类
package utils
import java.util.Date
import play.api.data.format._
import play.api.data.FormError
import play.api.data.Forms._
import play.api.data.Mapping
import views.html.helper.FieldConstructor
object Utils {
type Range[A] = (Option[A], Option[A])
case class Param(
name: Option[String],
birth: Range[Date],
height: Range[Int],
weight: Range[Int],
bust: Range[Int],
waist: Range[Int],
hip: Range[Int],
cup: Range[Char]
) {
def birth_sql = birth match {
case (Some(from), Some(to)) => (Some(new java.sql.Date(from.getTime)), Some(new java.sql.Date(to.getTime)))
case (None, Some(to)) => (None, Some(new java.sql.Date(to.getTime)))
case (Some(from), None) => (Some(new java.sql.Date(from.getTime)), None)
case (None, None) => (None, None)
}
}
private implicit def charFormat: Formatter[Char] = new Formatter[Char] {
def bind(key: String, data: Map[String, String]) =
data.get(key).filter(s => s.length == 1 && s != " ").map(s => Right(s.charAt(0))).getOrElse(
Left(Seq(FormError(key, "error.required", Nil)))
)
def unbind(key: String, value: Char) = Map(key -> value.toString)
}
val char = of[Char]
implicit val fieldConstructor = FieldConstructor(views.html.fieldConstructor.f)
}