diff --git a/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php b/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php index 59f39fe..45aeeb2 100644 --- a/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php +++ b/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php @@ -24,6 +24,16 @@ public function testUseTag() { ' label', '/label' )); + + $result = $this->Html->useTag( + 'radio', 'one', 'two', array('class' => 'radio-inline', 'three' => 'four'), '' + ); + $this->assertTags($result, array( + 'label' => array('class' => 'radio-inline', 'for' => 'one'), + 'input' => array('type' => 'radio', 'name' => 'one', 'id' => 'two', 'three' => 'four'), + ' label', + '/label' + )); } public function testImage() { diff --git a/View/Helper/BoostCakeHtmlHelper.php b/View/Helper/BoostCakeHtmlHelper.php index e7e56f0..2965a51 100644 --- a/View/Helper/BoostCakeHtmlHelper.php +++ b/View/Helper/BoostCakeHtmlHelper.php @@ -14,12 +14,18 @@ class BoostCakeHtmlHelper extends HtmlHelper { */ public function useTag($tag) { $args = func_get_args(); + + if ($tag === 'radio') { + $class = (isset($args[3]['class'])) ? $args[3]['class'] : 'radio'; + unset($args[3]['class']); + } + $html = call_user_func_array(array('parent', 'useTag'), $args); if ($tag === 'radio') { $regex = '/()/'; if (preg_match($regex, $html, $match)) { - $html = $match[1] . ' class="radio"' . $match[2] . preg_replace($regex, ' ', $html); + $html = $match[1] . ' class="' . $class . '"' . $match[2] . preg_replace($regex, ' ', $html); } }