Deprecated method addValidation and class CallbackValidator in Symfony2

Viewed 3098

I have a problem. I need to validate a field that is not in entity in form type class. Previously I used this code:

$builder->addValidator(new CallbackValidator(function(FormInterface $form){
    if (!$form['t_and_c']->getData()) {
        $form->addError(new FormError('Please accept the terms and conditions in order to registe'));
    }
}))

But since Symfony 2.1 method addValidator and class CallbackValidator are deprecated. Does anyone know what I should use instead?

3 Answers
Related