I have a very simple form without a class. I made some elements with restriction options, but form validation does not work.
I read several places ( for example, here ) I can add the validation_constraint parameter, which is an instance of \Symfony\Component\Validator\Constraints\Collection .
When I try, I always get an error message:
The validation_constraint parameter does not exist. The following options are known: ... blabla
My form:
$collectionConstraint = new \Symfony\Component\Validator\Constraints\Collection( array( 'customer' => new \Symfony\Component\Validator\Constraints\NotBlank(), 'customer_address' => new \Symfony\Component\Validator\Constraints\NotBlank(), 'customer_address_postal' => new \Symfony\Component\Validator\Constraints\NotBlank(), 'paymentDeadline' => new \Symfony\Component\Validator\Constraints\Date(), 'fulfillmentDate' => new \Symfony\Component\Validator\Constraints\Date(), 'currency' => new \Symfony\Component\Validator\Constraints\Choice(array( 'choices' => $currency_entities )), 'paymode' => new \Symfony\Component\Validator\Constraints\Choice(array( 'choices' => $paymode_entities )) ) ); $form = $this->createFormBuilder(null,array( 'validation_constraint' => $collectionConstraint )) ->add('customer','choice',array( 'choice_list'=> $customer_choices, 'multiple' => false, 'required' => true, 'empty_value' => '', 'attr' => array( 'class' => 'chosen large', ) )) ->add('customer_address','choice',array( 'multiple' => false, 'required' => true, 'empty_value' => '', 'attr' => array( 'class' => 'chosen large' ) )) ->add('customer_address_postal','choice',array( 'multiple' => false, 'required' => true, 'empty_value' => '', 'attr' => array( 'class' => 'chosen large' ) )) ->add('paymentDeadline','date',array( 'input' => 'datetime', 'widget' => 'single_text', 'required' => true, 'attr' => array( 'class' => 'date-picker m-ctrl-medium', 'addon' => 'icon-calendar', ) )) ->add('fulfillmentDate','date',array( 'input' => 'datetime', 'widget' => 'single_text', 'required' => true, 'attr' => array( 'class' => 'date-picker m-ctrl-medium', 'addon' => 'icon-calendar', ) )) ->add('currency','choice',array( 'required' => true, 'choice_list' => $curreny_choices )) ->add('paymode','choice',array( 'required' => true, 'choice_list' => $paymode_choices )) ->add('subject','text',array( 'required' => false, 'attr' => array( 'class' => 'span8' ) )) ->add('comment','textarea',array( 'required' => false, 'attr' => array( 'class' => 'span8', 'rows' => 5 ) )) ;
Symfony Version 2.3.3.
What could be the problem?