Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom input text label for play framework form

hi i have some problem with play framework forms

public class User extends Model{

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

}

and i create a form in my template using Form helper

@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/>

when i see the result my labels are printed the same as my User models fields like firstName but i want to have custom labels like "users first name" for my firstName field and "user last name" for my lastName field of my model what should i do? and how ?
any body can help?

like image 999
Keller123 Avatar asked May 23 '13 13:05

Keller123


2 Answers

Pass the label parameter like:

@inputText(objForm("firstName"), '_label -> "You label")
like image 197
Marco Avatar answered Oct 16 '22 19:10

Marco


use can use @helper class for the initialize the view and pass the parameter like:

@(contacts: List[models.Contact])

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

    @helper.inputText(form("name"), '_label -> "Name")
}
like image 44
arvind grey Avatar answered Oct 16 '22 19:10

arvind grey