Skip to content

Commit c59110d

Browse files
committed
Merge branch 'nchankov-master'
2 parents efc3959 + afcd019 commit c59110d

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ If you want to simplify the options, you can develop WrapBoostCake plugin.
4343
* Add `div` wrapping input
4444
* Add content before and after `input`
4545
* Add error class in outer `div`
46-
* Change pgination tags
47-
* Change SessionHelper::flash()`s tmplate
46+
* Change pagination tags
47+
* Change SessionHelper::flash()`s template

Test/Case/View/Helper/BoostCakeHtmlHelperTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ public function testUseTag() {
2424
' label',
2525
'/label'
2626
));
27+
28+
$result = $this->Html->useTag(
29+
'radio', 'one', 'two', array('class' => 'radio-inline', 'three' => 'four'), '<label for="one">label</label>'
30+
);
31+
$this->assertTags($result, array(
32+
'label' => array('class' => 'radio-inline', 'for' => 'one'),
33+
'input' => array('type' => 'radio', 'name' => 'one', 'id' => 'two', 'three' => 'four'),
34+
' label',
35+
'/label'
36+
));
2737
}
2838

2939
}

View/Helper/BoostCakeHtmlHelper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ class BoostCakeHtmlHelper extends HtmlHelper {
1414
*/
1515
public function useTag($tag) {
1616
$args = func_get_args();
17+
18+
if ($tag === 'radio') {
19+
$class = (isset($args[3]['class'])) ? $args[3]['class'] : 'radio';
20+
unset($args[3]['class']);
21+
}
22+
1723
$html = call_user_func_array(array('parent', 'useTag'), $args);
1824

1925
if ($tag === 'radio') {
2026
$regex = '/(<label)(.*?>)/';
2127
if (preg_match($regex, $html, $match)) {
22-
$html = $match[1] . ' class="radio"' . $match[2] . preg_replace($regex, ' ', $html);
28+
$html = $match[1] . ' class="' . $class . '"' . $match[2] . preg_replace($regex, ' ', $html);
2329
}
2430
}
2531

2632
return $html;
2733
}
2834

29-
}
35+
}

0 commit comments

Comments
 (0)