【发布时间】:2013-08-28 18:53:18
【问题描述】:
我有问题。我需要验证表单类型类中不在实体中的字段。以前我用过这段代码:
$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'));
}
}))
但由于 Symfony 2.1 方法 addValidator 和类 CallbackValidator 已被弃用。有谁知道我应该改用什么?
【问题讨论】:
-
CallbackValidator并没有被弃用,事实上,它是tagged as@api。
标签: php symfony-2.1