Hello. I'm Dean Clatworthy

I build websites for a living. PHP/MySQL, Javascript, CSS, HTML5

05 May 2013

You should be using custom constraints to validate your form fields, however there are some use-cases where you need to quickly invalidate in a controller. To do this it’s quite easy:

{% highlight php startinline %}

    $form->get('username')->addError(new \Symfony\Component\Form\FormError("This email is already in use"));

{% endhighlight %}