6

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

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)打印相同,但我希望我的firstName字段具有自定义标签,例如“用户名字”和模型的lastName字段的“用户姓氏”应该我做?如何 ? 任何机构都可以提供帮助吗?

4

2 回答 2

22

传递标签参数,如:

@inputText(objForm("firstName"), '_label -> "You label")
于 2013-05-23T15:16:34.867 回答
1

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

@(contacts: List[models.Contact])

  @helper.form(action = routes.Contacts.create) {

    @helper.inputText(form("name"), '_label -> "Name")
}
于 2017-06-27T12:14:42.437 回答