I am trying to upgrade my project from symfony2 to symfony3. I want to get rid of this deprecation warning
The "cascade_validation" option is deprecated since version 2.8 and will be removed in 3.0. Use "constraints" with a Valid constraint instead."
Below is my code
->add('student_name', 'collection', array(
'entry_type' => TextType::class,
'allow_add' => true,
'cascade_validation' => true,
'options' => array(
'required' => false
)
))
Can I just remove this line 'cascade_validation' => true
without causing any trouble? Or what would be the equivalent code in symfony3?
Just replace
'cascade_validation' => true, with 'constraints' => new \Symfony\Component\Validator\Constraints\Valid(),
In Symfony3 you have to use @Assert\Valid
constraint in your parent entity. You can remove the line 'cascade_validation' => true
in your FormType class.
class Author
{
/**
* @Assert\Valid
*/
protected $address;
}
http://symfony.com/doc/current/reference/constraints/Valid.html
This Symfony commit contains the change and full example how to upgrade.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With