diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 93dbc3bc2..0193ad07e 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -812,17 +812,17 @@ class Controller extends Object { $otherModelKey = Inflector::underscore($assocData['className']); $otherModelObj = &ClassRegistry::getObject($otherModelKey); if ($doCreateOptions) { - $fieldNames[$otherModelKey]['model'] = $associationName; - $fieldNames[$otherModelKey]['label'] = "Related " . Inflector::humanize(Inflector::pluralize($associationName)); - $fieldNames[$otherModelKey]['prompt'] = $fieldNames[$otherModelKey]['label']; - $fieldNames[$otherModelKey]['type'] = "select"; - $fieldNames[$otherModelKey]['multiple'] = "multiple"; - $fieldNames[$otherModelKey]['tagName'] = $associationName . '/' . $associationName; - $fieldNames[$otherModelKey]['name'] = $associationName; - $fieldNames[$otherModelKey]['class'] = 'optional'; - $fieldNames[$otherModelKey]['options'] = $otherModelObj->generateList(); + $fieldNames[$associationName]['model'] = $associationName; + $fieldNames[$associationName]['label'] = "Related " . Inflector::humanize(Inflector::pluralize($associationName)); + $fieldNames[$associationName]['prompt'] = $fieldNames[$associationName]['label']; + $fieldNames[$associationName]['type'] = "select"; + $fieldNames[$associationName]['multiple'] = "multiple"; + $fieldNames[$associationName]['tagName'] = $associationName . '/' . $associationName; + $fieldNames[$associationName]['name'] = $associationName; + $fieldNames[$associationName]['class'] = 'optional'; + $fieldNames[$associationName]['options'] = $otherModelObj->generateList(); if (isset($data[$associationName])) { - $fieldNames[$otherModelKey]['selected'] = $this->_selectedArray($data[$associationName], $otherModelObj->primaryKey); + $fieldNames[$associationName]['selected'] = $this->_selectedArray($data[$associationName], $otherModelObj->primaryKey); } } } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 2112afaac..20c963869 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -211,7 +211,7 @@ class DboSource extends DataSource { if (isset($params[2 + $off])) { $order = $params[2 + $off]; } - + if(!array_key_exists(0, $params)) { return false; } diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 896ad0899..8228e36a2 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -119,9 +119,9 @@ var $belongsTo = array( 'ArticleFeatured'=> array('className' => 'ArticleFeatured'), 'Category'=> array('className' => 'Category') - ); + ); } - + /** * Short description for class. * @@ -682,9 +682,9 @@ class ModelTest extends CakeTestCase { ) ); $this->assertEqual($result, $expected); - + $this->Featured = new Featured(); - + $this->Featured->recursive = 2; $this->Featured->bindModel(array( 'belongsTo' => array( @@ -694,103 +694,105 @@ class ModelTest extends CakeTestCase { ) ) )); - + $this->Featured->ArticleFeatured->unbindModel(array( - 'hasMany' => array('Attachment', 'Comment'), + 'hasMany' => array('Attachment', 'Comment'), 'hasAndBelongsToMany'=>array('Tag')) ); - + // UNCOMMENT THE FOLLOWING LINE TO MAKE TEST SUCCEED: // // $this->Featured->ArticleFeatured->unbindModel(array('belongsTo'=>array('Category'))); - + $orderBy = 'ArticleFeatured.id ASC'; $result = $this->Featured->findAll(null, null, $orderBy, 3); - - $expected = array ( - array ( - 'Featured' => array ( - 'id' => '1', - 'article_featured_id' => '1', - 'category_id' => '1', - 'published_date' => '2007-03-31 10:39:23', - 'end_date' => '2007-05-15 10:39:23', - 'created' => '2007-03-18 10:39:23', + + $expected = array ( + array ( + 'Featured' => array ( + 'id' => '1', + 'article_featured_id' => '1', + 'category_id' => '1', + 'published_date' => '2007-03-31 10:39:23', + 'end_date' => '2007-05-15 10:39:23', + 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'ArticleFeatured' => array ( - 'id' => '1', - 'title' => 'First Article', - 'user_id' => '1', - 'published' => 'Y', - 'User' => array ( - 'id' => '1', - 'user' => 'mariano', - 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - 'created' => '2007-03-17 01:16:23', + ), + 'ArticleFeatured' => array ( + 'id' => '1', + 'title' => 'First Article', + 'user_id' => '1', + 'published' => 'Y', + 'User' => array ( + 'id' => '1', + 'user' => 'mariano', + 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', + 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Featured' => array ( - 'id' => '1', - 'article_featured_id' => '1', - 'category_id' => '1', - 'published_date' => '2007-03-31 10:39:23', - 'end_date' => '2007-05-15 10:39:23', - 'created' => '2007-03-18 10:39:23', + ), + 'Featured' => array ( + 'id' => '1', + 'article_featured_id' => '1', + 'category_id' => '1', + 'published_date' => '2007-03-31 10:39:23', + 'end_date' => '2007-05-15 10:39:23', + 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' ) - ), - 'Category' => array ( - 'id' => '1', - 'parent_id' => '0', - 'name' => 'Category 1', - 'created' => '2007-03-18 15:30:23', + ), + 'Category' => array ( + 'id' => '1', + 'parent_id' => '0', + 'name' => 'Category 1', + 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' ) - ), - array ( - 'Featured' => array ( - 'id' => '2', - 'article_featured_id' => '2', - 'category_id' => '1', - 'published_date' => '2007-03-31 10:39:23', - 'end_date' => '2007-05-15 10:39:23', - 'created' => '2007-03-18 10:39:23', + ), + array ( + 'Featured' => array ( + 'id' => '2', + 'article_featured_id' => '2', + 'category_id' => '1', + 'published_date' => '2007-03-31 10:39:23', + 'end_date' => '2007-05-15 10:39:23', + 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'ArticleFeatured' => array ( - 'id' => '2', - 'title' => 'Second Article', - 'user_id' => '3', - 'published' => 'Y', - 'User' => array ( - 'id' => '3', - 'user' => 'larry', - 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - 'created' => '2007-03-17 01:20:23', + ), + 'ArticleFeatured' => array ( + 'id' => '2', + 'title' => 'Second Article', + 'user_id' => '3', + 'published' => 'Y', + 'User' => array ( + 'id' => '3', + 'user' => 'larry', + 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', + 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Featured' => array ( - 'id' => '2', - 'article_featured_id' => '2', - 'category_id' => '1', - 'published_date' => '2007-03-31 10:39:23', - 'end_date' => '2007-05-15 10:39:23', - 'created' => '2007-03-18 10:39:23', + ), + 'Featured' => array ( + 'id' => '2', + 'article_featured_id' => '2', + 'category_id' => '1', + 'published_date' => '2007-03-31 10:39:23', + 'end_date' => '2007-05-15 10:39:23', + 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' ) - ), - 'Category' => array ( - 'id' => '1', - 'parent_id' => '0', - 'name' => 'Category 1', - 'created' => '2007-03-18 15:30:23', + ), + 'Category' => array ( + 'id' => '1', + 'parent_id' => '0', + 'name' => 'Category 1', + 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' ) ) ); - + $this->assertEqual($result, $expected); + debug($result); + debug($expected); } function testSaveField() {