I'm using Symfony V2.6.3
I have a simple form with three fields based on a Type class.
The Entity class that the Type class specifies via setDefaultOptions()
has the use Symfony\Component\Validator\Constraints as Assert;
statement.
Each field has an @Assert\NotBlank()
constraint in the Entity class.
CSRF is enabled.
HTML5 validation is disabled.
If I submit the form with all fields blank, the following happens:
- In the controller:
isValid()
returns falsegetErrors( true )
returns an error for each field
- In the template:
{{ form_errors( form ) }}
generates no text for the form or any of the fields.
I created a custom form theme and modified {% block form_errors %}
to
dump the errors
variable. The dump shows the errors
property is a FormErrorIterator
object with two properties: form
, which is, I believe the field definition, and errors
which is an empty array.
Oddly enough, drilling down into the form
property reveals an errors
property that is an array with a single FormError
object that contains the error message.
This is not my first time using forms. It has worked just fine for me in the past. Could this be a new bug in 2.6?
I have searched for this and all I found were situations where getErrors()
was also returning nothing.
Thanks in advance, Dave