I'd like to be able to add in a Form class additional validation constraints for a specific validation group. How could I do that ?
Since Symfony 2.1, adding a validation while building the form looks like this :
use Symfony\Component\Validator\Constraints\MinLength;
use Symfony\Component\Validator\Constraints\NotBlank;
$builder
->add('firstName', 'text', array(
'constraints' => new MinLength(3),
))
->add('lastName', 'text', array(
'constraints' => array(
new NotBlank(),
new MinLength(3),
),
))
;
Is there a way to assign them to a validation constraint ?
In my case, I have validation groups depending on submitted data
Thanks in advance for your suggestions