diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index f5f42067f..353fc9a66 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -629,9 +629,9 @@ class View extends Object { ($count == 1 && !empty($this->association)) || ($count == 1 && $this->model != $this->entityPath) || ($count == 2 && !empty($this->fieldSuffix)) || - is_numeric($path[0]) + is_numeric($path[0]) && !empty($assoc) ) { - array_unshift($path,$assoc); + array_unshift($path, $assoc); } return Set::filter($path); } diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 03ee9c681..76ec57f91 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -891,6 +891,14 @@ class ViewTest extends CakeTestCase { $View->association = 'Comment'; $View->field = 'user_id'; $this->assertEqual($View->entity(), array('Comment', 'user_id')); + + $View->model = 0; + $View->association = null; + $View->field = 'Node'; + $View->fieldSuffix = 'title'; + $View->entityPath = '0.Node.title'; + $expected = array(0, 'Node', 'title'); + $this->assertEqual($View->entity(), $expected); } /**