Skip to content

Commit

Permalink
fixed CONFLICT
Browse files Browse the repository at this point in the history
  • Loading branch information
slywalker committed Jul 19, 2013
2 parents a8e412a + c59110d commit b13b9d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Test/Case/View/Helper/BoostCakeHtmlHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public function testUseTag() {
' label',
'/label'
));

$result = $this->Html->useTag(
'radio', 'one', 'two', array('class' => 'radio-inline', 'three' => 'four'), '<label for="one">label</label>'
);
$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() {
Expand Down
8 changes: 7 additions & 1 deletion View/Helper/BoostCakeHtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '/(<label)(.*?>)/';
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);
}
}

Expand Down

0 comments on commit b13b9d3

Please sign in to comment.