Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2中的约束与验证组_Php_Forms_Validation_Symfony - Fatal编程技术网

Php Symfony2中的约束与验证组

Php Symfony2中的约束与验证组,php,forms,validation,symfony,Php,Forms,Validation,Symfony,我已在我的表单中启用了验证\u组 $resolver->setDefaults([ 'translation_domain' => 'general', 'data_class' => 'Software\Bundle\Entity\User', 'attr' => ['novalidate' => 'novalidate'], 'c

我已在我的表单中启用了
验证\u组

    $resolver->setDefaults([
        'translation_domain'    => 'general',
        'data_class'            => 'Software\Bundle\Entity\User',
        'attr'                  => ['novalidate' => 'novalidate'],
        'cascade_validation'    => true,
        'validation_groups'     => ['registration']
    ]);
而User.yml文件包含

    emailAddress:
        - NotBlank:
            groups: [registration]
然而,在我的FormBuilder方法中,我有额外的自定义约束

    $options = [
        'label' => 'word.email_address',
        'constraints'=> [
            new HasUsername($this->getOption('uuid'))
        ]
    ];

    return $builder->add('emailAddress', 'email', $options);
问题是,由于启用了
validation\u groups
,因此从未调用表单生成器中的表单。因为当我禁用
验证\u组时,会调用自定义组

是否可以让
验证组
约束和表单生成器中的约束同时工作


我需要在form builder中调用自定义约束的原因是,我需要传递重要变量
uuid
,以便正确检查用户所属的
uuid

在验证组属性中使用默认值

'validation_groups'     => ['registration', 'Default']