I have a form that contains a user entity with an $email
property:
{{ form_start(form, {'attr': {'class':'form-horizontal'} }) }}
{{ form_errors(form) }}
...
<div class="control-group formSep">
<label class="control-label">
{{ form_label(form.email, 'E-mail:') }}
</label>
<div class="controls text_line">
{{ form_widget(form.email) }}
</div>
</div>
...
{{ form_rest(form) }}
{{ form_end(form) }}
The user entity has constraints on $email
:
/**
* @ORM\Column(type="string", length=64)
* @Assert\Email
* @Assert\NotBlank
*/
protected $email;
When I put an invalid e-mail value the entity does not persist in the database (good), but twig doesn't display the error either (bad).
Any ideas?
like said in the documentation form_errors(form) render global errors (like class constraint errors, etc...), to display the error for the email field you should use form_errors(form.email).
http://symfony.com/doc/current/reference/forms/twig_reference.html#form-errors-view