diff --git a/README.md b/README.md index 9753482..707786b 100644 --- a/README.md +++ b/README.md @@ -43,5 +43,5 @@ If you want to simplify the options, you can develop WrapBoostCake plugin. * Add `div` wrapping input * Add content before and after `input` * Add error class in outer `div` -* Change pgination tags -* Change SessionHelper::flash()`s tmplate +* Change pagination tags +* Change SessionHelper::flash()`s template diff --git a/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php b/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php index 9d7f7f5..556e51a 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' + )); } } diff --git a/View/Helper/BoostCakeHtmlHelper.php b/View/Helper/BoostCakeHtmlHelper.php index da45083..f9cc6fd 100644 --- a/View/Helper/BoostCakeHtmlHelper.php +++ b/View/Helper/BoostCakeHtmlHelper.php @@ -14,16 +14,22 @@ 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); } } return $html; } -} \ No newline at end of file +}