From 9a4c186ccd93eacc323f791be0bc853491737412 Mon Sep 17 00:00:00 2001 From: joelmoss Date: Tue, 13 May 2008 23:09:37 +0000 Subject: [PATCH] Html::tag now accepts $attributes as a string, in which case, it will be used as the tags class name. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6859 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/html.php | 3 +++ cake/tests/cases/libs/view/helpers/html.test.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 730889924..32c027690 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -525,6 +525,9 @@ class HtmlHelper extends AppHelper { if ($escape) { $text = h($text); } + if (!is_array($attributes)) { + $attributes = array('class' => $attributes); + } if ($text === null) { $tag = 'tagstart'; } else { diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index fd12cc522..974d2a289 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -651,6 +651,9 @@ class HtmlHelperTest extends CakeTestCase { $result = $this->Html->tag('div', '', array('class' => 'class-name'), true); $this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); + + $result = $this->Html->tag('div', '', 'class-name', true); + $this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); } function testDiv() {