I am using Symfony 2.3.
I have created simple order form using $this->createFormBuilder
in my controller. I am validating one Doctrine field with:
/**
* @Assert\Length(min=3)
*/
protected $name;
However, upon validation fail, I get a duplicated error message near the field:
This value is too short. It should have 3 character or more.|This value is too short. It should have 3 characters or more.
My template for this element is as simple as:
{{ form_errors(form.name) }}
{{ form_label(form.name) }}
{{ form_widget(form.name) }}
Everything else seems to bet working as expected, except for that validation error message being duplicated. As if pluralization would not be working. Anyone has a suggestion on why this would be failing?
EDIT
It seems that SonataAdminBundle is overriding form_errors
block. How to remove that override from non-sonata controller?
The problem was that I had set this in my config.yml
:
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
form:
resources:
- 'SonataAdminBundle:Form:silex_form_div_layout.html.twig'
- 'SonataFormatterBundle:Form:formatter.html.twig'
The silex_form_div_layout.html.twig
one overrides form_errors
Twig block, and removing it fixes the problem.