Form template helpers '_error -> "Force an error"

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.

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.

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


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.