« Back to all articles

Silex Tip #1: How to quickly invalidate a form field in your controller

10 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:

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