Symfony 2.5中ValidatorConstraint的问题 [英] Problems with ValidatorConstraint in Symfony 2.5

查看:132
本文介绍了Symfony 2.5中ValidatorConstraint的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Symfony 2.4升级到2.5后,我的表单验证器约束不再工作。



我得到:可捕获致命错误:将参数1传递给Symfony \ Component \ Form \Extension\Validator\Type\FormTypeValidatorExtension :: __ construct()必须是Symfony \ Component \Validator\ValidatorInterface的一个实例,Symfony \ Component \Validator\Validator\的实例RecursiveValidator给出,定义在第36行的vendor / symfony / symfony / src / Symfony / Component / Form / Extension / Validator / Type / FormTypeValidatorExtension.php中。如何解决这个问题?

解决方案

尝试在config.yml中设置验证api。



来自UPGRADE-2.5.md的评论 https://github.com/symfony/symfony/blob/master/UPGRADE-2.5.md



Symfony \ Component \Validator\Validator 中的验证引擎被
替换为 Symfony \Component\\中的新引擎\\ Vididator \Validator \ RecursiveValidator
有了这样的改变,几个类已被弃用,它们将在
Symfony 3.0中被删除,并且验证器的API被稍微改变了。更多
的详细信息可以在UPGRADE-3.0中找到。



您可以通过
中新的api条目选择所需的API app / config / config.yml:




框架:
验证:
启用:true
api:auto


after upgrading from Symfony 2.4 to 2.5 my form validator constraints are not working any more.

I get: Catchable fatal error: Argument 1 passed to Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension::__construct() must be an instance of Symfony\Component\Validator\ValidatorInterface, instance of Symfony\Component\Validator\Validator\RecursiveValidator given, defined in vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php on line 36

Anybody has a suggestion how to fix this?

解决方案

Try setting the validation api in your config.yml.

Comment from the UPGRADE-2.5.md
https://github.com/symfony/symfony/blob/master/UPGRADE-2.5.md

"The validation engine in Symfony\Component\Validator\Validator was replaced by a new one in Symfony\Component\Validator\Validator\RecursiveValidator. With that change, several classes were deprecated that will be removed in Symfony 3.0. Also, the API of the validator was slightly changed. More details about that can be found in UPGRADE-3.0.

You can choose the desired API via the new "api" entry in app/config/config.yml:"

framework: validation: enabled: true api: auto

这篇关于Symfony 2.5中ValidatorConstraint的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆