Reputation:
Trying to pass in a value for a input in a form seems to yield no results. The documentation for the helper inputText shows a value option as a part of the creation of the input, but I am not sure how to pass in the desired parameters to the constructor.
I am passing in the parameters as follows:
@inputText(accountForm("accountName"), args = '_label -> "Account Name: ", '_value -> "Test")
Upvotes: 6
Views: 5594
Reputation: 121
You can fill in the Form
class as suggested by Li-o or can override the form value in the template itself like this. This will set it to "Test" or the value of "variable".
@inputText(accountForm("accountName").copy(value=Some("Test")), args = '_label -> "Account Name: ")
@inputText(accountForm("accountName").copy(value=Some(variable)), args = '_label -> "Account Name: ")
Upvotes: 11
Reputation: 1051
The value
parameter you see in the helper inputText
comes from the Field
class. If you want to give your field a default value, you have to set the value in your Controller. You can set default values by using the fill
method from the Form
class.
Note: there is also the HTML5 placeholder attribute. You can pass this attribute with the inputText helper: @inputText(accountForm("accountName"), 'placeholder -> "Test")
Upvotes: 6