custom input text label for play framework form
Asked Answered
P

2

6

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?

Psychophysics answered 23/5, 2013 at 13:8 Comment(0)
B
22

Pass the label parameter like:

@inputText(objForm("firstName"), '_label -> "You label")
Bluebill answered 23/5, 2013 at 15:16 Comment(0)
C
1

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")
}
Chavis answered 27/6, 2017 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.