在这个线程中,我与一个自定义验证器作斗争。感谢 stackoverflow 用户,我可以使用验证器。现在,我不能这样做显示错误。验证器类是:
class ExistEmailValidator extends ConstraintValidator
{
protected $userService;
public function setUserService($us) {
$this->userService = $us;
}
public function validate($value, Constraint $constraint)
{
if($this->userService->existUserEmail($value) == false){
$this->context->addViolation($constraint->message, array('%string%' => $value));
}
}
public function getTargets(){
return self::CLASS_CONSTRAINT;
}
}
我在树枝上写form_errors(myForm)
,但没有显示错误。验证器工作正常,但没有设置错误。
有任何想法吗 ?