小编Las*_*ina的帖子

Symfony 2:选项“ validation_constraint”不存在

我有一个非常简单的表格,没有上课。我做了一些带有约束选项的项目,但是表单验证不起作用。
我已经读过几个地方(例如在这里),我可以添加validation_constraint一个\Symfony\Component\Validator\Constraints\Collection实例参数。

当我尝试时,总是会收到错误消息:

选项“ validation_constraint”不存在。已知选项为:... blabla

我的表格:

$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'   => …
Run Code Online (Sandbox Code Playgroud)

forms validation symfony symfony-2.3

5
推荐指数
0
解决办法
5388
查看次数

标签 统计

forms ×1

symfony ×1

symfony-2.3 ×1

validation ×1