Playframework2 标签速记

1.@form

  • Example:
  • {{{
  • @form(action = routes.Users.submit, args = 'class -> “myForm”) {
  • }
  • }}}
    @helper.form(action = routes.Application.submit(), 'id -> “myForm”) {

}

2.@inputText(permissionform(“value”),'_label -> Messages(“permission.value”))

3.@inputText(myForm(“username”), 'id -> “username”, 'size -> 30)

4.@inputPassword(myForm(“password”))

注:添加额外的参数只需要使用
'参数名称 -> 值
的方式添加。
所有额外的参数将被添加到生成的HTML,名字的开头用“”字符的除外,加下划线的是保留参数。
保留参数开始用下划线场构造函数的参数
保留参数
'
label -> “Custom label”
'id -> “idForTheTopDlElement”
'
help -> “Custom help”
'showConstraints -> false
'
error -> “Force an error”
'showErrors -> false
'
default -> true | “选择菜单权限”

5.
@helper.input(myForm(“username”)) { (id, name, value, args) =>

<input type="date" name="@name" id="@id" @toHtmlArgs(args)>

}

6.@inputDate

  • Example:
  • {{{
  • @inputDate(field = myForm(“releaseDate”), args = 'size -> 10)
  • }}}

7.显示列表参数(假如myForm(“emails”) 是一个数组的会用到
@repeat(myForm(“emails”),min=1) { emailField =>

@inputText(emailField)

}

  1. @select
  2. Example:
  3. {{{
  4. @select(field = myForm(“isDone”), options = options(“Yes”,“No”))
  5. }}}
    @select(menuform(“menu.userpermission.id”),options(UserPermission.options()),'label -> Messages(“menu.userPermission”),'default ->“选择菜单权限”,'_showConstraints -> false)
    @select(
        field = helloForm("color"),
        options = options(
            "" -> "Default",
            "red" -> "Red",
            "green" -> "Green",
            "blue" -> "Blue"
        ),
        args = '_label -> "Choose a color"
    )
    
菜单权限
选择菜单权限 menu.edit menu.add admin.index menu.jsonsave menu.json menu.del

选择一个
<option class="blank" value="">选择菜单权限</option> <option value="3">menu.edit</option> <option value="2">menu.add</option> <option value="1">admin.index</option> <option value="6">menu.jsonsave</option> <option value="5">menu.json</option> <option value="4">menu.del</option>

  1. @checkbox
  2. Example:
  3. {{{
  4. @checkbox(field = myForm(“done”))
  5. }}}
    @checkbox(menuform(“enabled”),'label -> Messages(“menu.enabled”),'default -> true)

10.@inputFile

  • Example:
  • {{{
  • @inputFile(field = myForm(“name”), args = 'size -> 10)
  • }}}

11.@inputRadioGroup

  • Example:

  • {{{

  • @inputRadioGroup(

  •       contactForm("gender"),·
    
  •       options = options("M"->"Male","F"->"Female")
    
  •       '_label -> "Gender",
    
  •       '_error -> contactForm("gender").error.map(_.withMessage("select gender")))
    

    *

  • }}}

    12.@textarea

  • Example:

  • {{{

  • @textarea(field = myForm(“address”), args = 'rows -> 3, 'cols -> 50)

  • }}}

    13.@inputRadioGroup

  • Example:

  • {{{

  • @inputRadioGroup(

  •       contactForm("gender"),·
    
  •       options = options("M"->"Male","F"->"Female")
    
  •       '_label -> "Gender",
    
  •       '_error -> contactForm("gender").error.map(_.withMessage("select gender")))
    

    *

  • }}}

@inputRadioGroup( menuform(“menu.userpermission.id”),options = options(UserPermission.options()),'_label -> “Gender1”,'data_check -> “notBlank”)
生成的代码如下:

Gender1
menu.edit menu.add admin.index menu.jsonsave menu.json menu.del

你可能感兴趣的:(playframework2)