I\'ve got a form with extra fields added with the option mapped
to false
. But when I try to validate my form, it won\'t pass indicating \"this valu
As I mentionned in a question on a similar topic, since Symfony 2.1, you should use the 'constraints' option to add validation to your un-mapped fields:
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),
),
))
;
Hope it will help anybody like me who lost some time on this...