浏览代码

Fixed validation error message displaying in form

Now the error message is displayed next to the property form field when use assert<ConstrainName> method for validation
Removed deprecated method call.
Artem Ponomarenko 12 年之前
父节点
当前提交
bbd94e82a2
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      Validator/ErrorElement.php

+ 5 - 5
Validator/ErrorElement.php

@@ -110,11 +110,9 @@ class ErrorElement
      */
     protected function validate(Constraint $constraint)
     {
-        $validator = $this->constraintValidatorFactory->getInstance($constraint);
-        $value     = $this->getValue();
+        $subPath = (string) $this->getCurrentPropertyPath();
 
-        $validator->initialize($this->context);
-        $validator->validate($value, $constraint);
+        $this->context->validateValue($this->getValue(), $constraint, $subPath, $this->group);
     }
 
     /**
@@ -191,7 +189,9 @@ class ErrorElement
             $message    = isset($message[0]) ? $message[0] : 'error';
         }
 
-        $this->context->addViolationAtPath($this->getFullPropertyPath(), $message, $parameters, $value);
+        $subPath = (string) $this->getCurrentPropertyPath();
+
+        $this->context->addViolationAt($subPath, $message, $parameters, $value);
 
         $this->errors[] = array($message, $parameters, $value);