【问题标题】:custom input text label for play framework form播放框架表单的自定义输入文本标签
【发布时间】:2013-05-23 13:08:06
【问题描述】:

嗨,我对游戏框架表单有一些问题

public class User extends Model{

    public String firstName;
    @Required
    public String lastName;
    @Required
    public String password;
    @Required
    public boolean bedAccess;

}

我使用表单助手在我的模板中创建了一个表单

@form(routes.Application.createUser()) {
      <table border="1" class="inserTable">
      <tbody>
            <tr>
        <td>@inputText(userForm("firstName"))</td>
        <td>@inputText(userForm("lastName"))</td>
        <td>@inputPassword(userForm("password"))</td>
        <td>@checkbox(userForm("bedAcces"))</td> 
                <td><input type="submit" value="Create"> <td/>
                </tr>
           <tbody/>

<br/>

当我看到结果时,我的标签打印与我的用户模型字段(如 firstName)相同,但我希望为我的用户自定义标签,如“users first name”我的模型的 lastName 字段的 firstName 字段和“用户姓氏”我应该怎么做? 如何 ?
任何机构都可以提供帮助?

【问题讨论】:

    标签: playframework-2.0


    【解决方案1】:

    像这样传递标签参数:

    @inputText(objForm("firstName"), '_label -> "You label")
    

    【讨论】:

      【解决方案2】:

      使用可以使用@helper类来初始化视图并传递参数:

      @(contacts: List[models.Contact])
      
        @helper.form(action = routes.Contacts.create) {
      
          @helper.inputText(form("name"), '_label -> "Name")
      }
      

      【讨论】:

        猜你喜欢
        • 2013-08-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-10
        • 2012-02-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多