diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 3cfe67331..dc3eabe8a 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1419,7 +1419,11 @@ class Model extends Overloadable { } } } + $this->validationErrors = $validationErrors; + if (isset($validationErrors[$this->alias])) { + $this->validationErrors = $validationErrors[$this->alias]; + } switch (true) { case ($options['validate'] === 'only'): diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index b012b9cf8..aed9ce03c 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -2222,7 +2222,8 @@ class ModelTest extends CakeTestCase { 'Comment' => array('comment' => 'This field cannot be left blank'), 'Attachment' => array('attachment' => 'This field cannot be left blank') ); - $this->assertEqual($model->validationErrors, $expected); + $this->assertEqual($model->validationErrors, $expected['Comment']); + $this->assertEqual($model->Attachment->validationErrors, $expected['Attachment']); $this->assertFalse($model->saveAll( array( @@ -2231,7 +2232,8 @@ class ModelTest extends CakeTestCase { ), array('validate' => 'only') )); - $this->assertEqual($model->validationErrors, $expected); + $this->assertEqual($model->validationErrors, $expected['Comment']); + $this->assertEqual($model->Attachment->validationErrors, $expected['Attachment']); } function testSaveAllAtomic() { @@ -2498,7 +2500,8 @@ class ModelTest extends CakeTestCase { $result = $model->find('all'); $this->assertEqual($result, array()); $expected = array('Comment' => array(0 => array('comment' => 'This field cannot be left blank'))); - $this->assertEqual($model->validationErrors, $expected); + + $this->assertEqual($model->Comment->validationErrors, $expected['Comment']); $this->assertIdentical($model->Comment->find('count'), 0);