I have problem with clearing all validation constraint that extend from super class. Below is my code
User.php
* @var string
* @ORM\Column(type="text", unique=true)
* @Assert\NotBlank()
* @Assert\NotNull()
* @AdminAssert\MyCustomValidation
*/
protected $phoneNumber;
In Admin.php I wrote code something like below
class Admin extends User
* @var string
* @ORM\Column(type="text", unique=true)
*/
protected $phoneNumber;
I want to remove all validation constraints but can't remove it.
For disabling the validation of a form you can set the validation_groups option to false, as described here in the doc.
In your case you can check the class data (as described here in the doc) for disabling or not the form validation, as example:
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'validation_groups' => function (FormInterface $form) {
$data = $form->getData();
if ($data instanceof Admin) {
return;
}
return array('Default');
},
));
}
Hovenever in your code i see a a custom validation on admin validation, if so consider to use the validation groups.
Hope this help
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