Greetings,
I am unable to generate a test error, per the Form template helpers documentation only available in Java for 2.6
@helper.inputText(loginForm("email"),
'_label -> "",
'_showConstraints -> true,
'placeholder -> "acme@example.com",
'type -> "email",
'class -> "form-control",
'_error -> "Force an error",
'_showErrors -> true
)
Am I doing something wrong?
Let me know,
Thanks,
Hey @AlbaroPereyra ,
It was unclear to me what you are trying to do and what is the problem. Are you trying to write a test for your forms? If so, is it a unit test or an acceptance test? Can you share the code and clarify what you are seeing and what you are expecting to see?
Best.
AlbaroPereyra:
template helpers
To my understanding the following property
'_error → “Force an error”
Is suppose to force an error per the following guide:
"
This default field constructor supports additional options you can pass in the input helper arguments:
'_label -> "Custom label"
'_id -> "idForTheTopDlElement"
'_help -> "Custom help"
'_showConstraints -> false
'_error -> "Force an error"
'_showErrors -> false
"
I am trying to see fake error in the form.
mkurz
(Matthias Kurz)
February 20, 2019, 1:05pm
4
@AlbaroPereyra is right. The '_error
param doesn’t do what it is supposed to do: It does not handle a string.
However, looking at the code:
(args.get('_error) match {
case Some(Some(play.api.data.FormError(_, message, args))) =>
Some(Seq(p.messages(message, args.map(a => translateMsgArg(a)): _*)))
case _ => None
}).getOrElse {
what it does handle is Some(formErrorObject)
meaning you can right now write
'_error -> Some(FormError("foo", "Force an error"))
to force an error.
I opened a pull request to fix this:
If this gets merged you can finally write
'_error -> Some("Force an error")
// or
'_error -> "Force an error"
like the doc says.