Playframework2 標籤速記

1.@formjson

  • 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)spa

4.@inputPassword(myForm("password")).net

注:添加額外的參數只須要使用 '參數名稱 -> 值 的方式添加。 全部額外的參數將被添加到生成的HTML,名字的開頭用「_」字符的除外,加下劃線的是保留參數。 保留參數開始用下劃線場構造函數的參數 保留參數 '_label -> "Custom label" '_id -> "idForTheTopDlElement" '_help -> "Custom help" '_showConstraints -> false '_error -> "Force an error" '_showErrors -> false '_default -> true | "選擇菜單權限"code

@helper.input(myForm("username")) { (id, name, value, args) => <input type="date" name="@name" id="@id" @toHtmlArgs(args)> }orm

6.@inputDateget

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

7.顯示列表參數(假如myForm("emails") 是一個數組的會用到 @repeat(myForm("emails"),min=1) { emailField => @inputText(emailField) }input

  1. @select
  • Example:
  • {{{
  • @select(field = myForm("isDone"), options = options("Yes","No"))
  • }}}
    @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" )

<div class="control-group"> <label class="control-label" for="menu_userpermission_id">菜單權限</label> <div class="controls"> <select id="menu_userpermission_id" name="menu.userpermission.id"> <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> </select> </div> </div> 選擇一個 <select id="menu_userpermission_id" data_check='select(1)' showName="菜單權限" name="menu.userpermission.id"> <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> </select>it

  1. @checkbox
  • Example:
  • {{{
  • @checkbox(field = myForm("done"))
  • }}}
    @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") 生成的代碼以下:

<div class="control-group"> <label class="control-label" for="menu_userpermission_id">Gender1</label> <div class="controls"> <span id="menu_userpermission_id" class="buttonset"> <input id="menu_userpermission_id_3" type="radio" data_check="notBlank" value="3" name="menu.userpermission.id"> <label for="menu_userpermission_id_3">menu.edit</label> <input id="menu_userpermission_id_2" type="radio" data_check="notBlank" value="2" name="menu.userpermission.id"> <label for="menu_userpermission_id_2">menu.add</label> <input id="menu_userpermission_id_1" type="radio" data_check="notBlank" value="1" name="menu.userpermission.id"> <label for="menu_userpermission_id_1">admin.index</label> <input id="menu_userpermission_id_6" type="radio" data_check="notBlank" value="6" name="menu.userpermission.id"> <label for="menu_userpermission_id_6">menu.jsonsave</label> <input id="menu_userpermission_id_5" type="radio" data_check="notBlank" value="5" name="menu.userpermission.id"> <label for="menu_userpermission_id_5">menu.json</label> <input id="menu_userpermission_id_4" type="radio" data_check="notBlank" value="4" name="menu.userpermission.id"> <label for="menu_userpermission_id_4">menu.del</label> </span> </div> </div>

相關文章
相關標籤/搜索