我正在尝试将我的项目从symfony2升级到symfony3.我想摆脱这个弃用警告
The "cascade_validation" option is deprecated since version 2.8 and will be removed in 3.0. Use "constraints" with a Valid constraint instead."
Run Code Online (Sandbox Code Playgroud)
以下是我的代码
->add('student_name', 'collection', array(
'entry_type' => TextType::class,
'allow_add' => true,
'cascade_validation' => true,
'options' => array(
'required' => false
)
))
Run Code Online (Sandbox Code Playgroud)
我可以在'cascade_validation' => true不造成任何麻烦的情况下删除此行吗?或者symfony3中的等效代码是什么?
Jib*_*ato 15
在Symfony3中,您必须@Assert\Valid在父实体中使用约束.您可以删除'cascade_validation' => trueFormType类中的行.
class Author
{
/**
* @Assert\Valid
*/
protected $address;
}
Run Code Online (Sandbox Code Playgroud)
http://symfony.com/doc/current/reference/constraints/Valid.html
小智 13
只需更换
'cascade_validation' => true, with 'constraints' => new \Symfony\Component\Validator\Constraints\Valid(),