Closed florianschneider closed 7 years ago
Hi @florianschneider,
The API for the plugin allows Option[FormError]
as parameter to '_error
because it could be useful for example if you would like to add a global error for the form within a specific field (global errors lets you to validate the fields all together).
For the other hand, querying fooForm("bar").errors
should be a Seq[FormError]
as it is said at the Play's API.
https://www.playframework.com/documentation/2.5.x/api/scala/index.html#play.api.data.Field
So it doesn't seem related to this plugin. Please, check this file, it may be useful: https://github.com/playframework/playframework/blob/2.5.13/framework/src/play/src/main/scala/play/api/data/Form.scala
However, I'll try to find out more when I get some time. Could you put here some code example?
Thanks @adrianhurt for the quick reply. The issue certainly seems unrelated to your plugin, however I thought there might be some new development you were not supporting yet. The Play API documentation proves me wrong....
What I'm still not understanding is why the form object provides ValidationError instances at runtime in spite of the API docs stating there would be FormError instances. Well, maybe in parts, the validate method of a bean would return ValidationError objects, so at least I know where this is coming from. Look here. I just quickly constructed a play project from the play-java-intro template, without embedding play-bootstrap yet, just in order to show that form.globalErrors seems to deliver ValidationError objects. If you're interested, I can upload it.
Oddly, under certain circumstances, the error display of your form helper works without me even specifying something for the '_error symbol. Now I'm completely confused.
Hi @florianschneider, did you find the problem?
Yeah, I was just confused by the debug output. As long as the id of the field in question is set correctly, the errors are correctly displayed without an explicit specification of _error in the helper.
Your API for rendering validation state allows Option[play.api.data.FormError] as parameter to '_error . However, when querying fooForm("barAttribute").errors , I receive instances of play.api.data.validation.ValidationError. Am I getting something conceptually wrong here?