From 71790792d08de9d0b20a83f6f574238bbea337be Mon Sep 17 00:00:00 2001 From: the_undefined Date: Mon, 19 May 2008 02:31:26 +0000 Subject: [PATCH] Applied patch by 'preloader', closes #4561 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6937 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/model.php | 4 ++++ cake/tests/cases/libs/model/model.test.php | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) 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);