User input text label for the play form form

Hi, I have some problems with the forms of the game.

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 a 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 print the same way as the fields of my user models, such as firstName , but I want to have custom labels like "username" for my firstName and "username" for my lastName field of my model, which should i do? And How?
can any body help?

+6
source share
2 answers

Pass the label parameter, for example:

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

use can use the @helper class to initialize the view and pass a parameter, for example:

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

Source: https://habr.com/ru/post/945683/


All Articles