diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index d3271f9fb..c20737b19 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -834,7 +834,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $saveLater = $conn->saveRelated($this); - if( ! $this->isValid()) { + $this->isValid(); + + if($this->errorStack->count() > 0) { $conn->getTransaction()->addInvalid($this); } else { $conn->save($this); diff --git a/lib/Doctrine/Validator/ErrorStack.php b/lib/Doctrine/Validator/ErrorStack.php index 2cdf86dc8..9ad42222e 100644 --- a/lib/Doctrine/Validator/ErrorStack.php +++ b/lib/Doctrine/Validator/ErrorStack.php @@ -26,7 +26,7 @@ Doctrine::autoload('Doctrine_Access'); * @license LGPL * @package Doctrine */ -class Doctrine_Validator_ErrorStack extends Doctrine_Access { +class Doctrine_Validator_ErrorStack extends Doctrine_Access implements Countable, IteratorAggregate { private $errors = array(); @@ -42,8 +42,15 @@ class Doctrine_Validator_ErrorStack extends Doctrine_Access { return null; } - + public function set($name, $value) { - $this->errors[$name] = $value; + $this->errors[$name] = $value; + } + + public function getIterator() { + return new ArrayIterator($this->errors); + } + public function count() { + return count($this->errors); } }