diff --git a/src/View/Helper/HtmlHelper.php b/src/View/Helper/HtmlHelper.php index db61c9ea949..2f518e58625 100644 --- a/src/View/Helper/HtmlHelper.php +++ b/src/View/Helper/HtmlHelper.php @@ -1076,6 +1076,11 @@ public function media($path, array $options = array()) { /** * Build a nested list (UL/OL) out of an associative array. * + * Options for $itemOptions: + * + * - `even` - Class to use for even rows. + * - `odd` - Class to use for odd rows. + * * @param array $list Set of elements to list * @param string|array $options Additional HTML attributes of the list (ol/ul) tag or if ul/ol use that as tag * @param array $itemOptions Additional HTML attributes of the list item (LI) tag @@ -1083,11 +1088,7 @@ public function media($path, array $options = array()) { * @return string The nested list * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::nestedList */ - public function nestedList($list, $options = array(), array $itemOptions = array(), $tag = 'ul') { - if (is_string($options)) { - $tag = $options; - $options = array(); - } + public function nestedList(array $list, array $options = array(), array $itemOptions = array(), $tag = 'ul') { $items = $this->_nestedListItem($list, $options, $itemOptions, $tag); return $this->formatTemplate($tag, [ 'attrs' => $this->templater()->formatAttributes($options), @@ -1105,7 +1106,7 @@ public function nestedList($list, $options = array(), array $itemOptions = array * @return string The nested list element * @see HtmlHelper::nestedList() */ - protected function _nestedListItem($items, $options, array $itemOptions, $tag) { + protected function _nestedListItem($items, $options, $itemOptions, $tag) { $out = ''; $index = 1; diff --git a/tests/TestCase/View/Helper/HtmlHelperTest.php b/tests/TestCase/View/Helper/HtmlHelperTest.php index 16ff1201d79..3634a0f18e9 100644 --- a/tests/TestCase/View/Helper/HtmlHelperTest.php +++ b/tests/TestCase/View/Helper/HtmlHelperTest.php @@ -1318,7 +1318,7 @@ public function testNestedList() { ); $this->assertTags($result, $expected); - $result = $this->Html->nestedList($list, null); + $result = $this->Html->nestedList($list); $this->assertTags($result, $expected); $result = $this->Html->nestedList($list, array(), array(), 'ol'); @@ -1351,9 +1351,6 @@ public function testNestedList() { ); $this->assertTags($result, $expected); - $result = $this->Html->nestedList($list, 'ol'); - $this->assertTags($result, $expected); - $result = $this->Html->nestedList($list, array('class' => 'list')); $expected = array( array('ul' => array('class' => 'list')),