Browse files

Merge pull request #12 from jiminy/master

fix EConditionalValidator::validateAttribute()
  • Loading branch information...
2 parents ab0829e + 6acb0ac commit 7a622b700d2f0cb36ae50f598ba7de398faad6b9 @tonydspaniard committed Nov 6, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 validators/EConditionalValidator/EConditionalValidator.php
View
10 validators/EConditionalValidator/EConditionalValidator.php
@@ -65,19 +65,17 @@ class EConditionalValidator extends CValidator {
/**
* Validates the attribute of the object.
* If there is any error, the error message is added to the object.
- * @param CModel the object being validated
- * @param string the attribute being validated
+ * @param CModel $object the object being validated
+ * @param string $attribute the attribute being validated
*/
protected function validateAttribute($object, $attribute)
{
- $obj = get_class($object);
- $obj = new $obj();
- $obj->setAttributes($object->getAttributes());
+ $obj = clone $object;
if (!$this->skipConditional && !$this->validateConditional($obj, $this->conditionalRules))
return false;
- $validator = CValidator::createValidator($this->rule[0], $object, $attribute, array_splice($this->rule, 1));
+ $validator = CValidator::createValidator($this->rule[0], $object, $attribute, array_slice($this->rule, 1, null, true));
$validator->validate($object);
$obj = null;
}

0 comments on commit 7a622b7

Please sign in to comment.