Skip to content
Permalink
Browse files

Add generated classnames to labels for multiple checkboxes.

The old FormHelper code would add a classname of 'selected' to a label
when the checkbox was selected. Keep this behavior in the new widget
class.
  • Loading branch information...
markstory committed Feb 19, 2014
1 parent 52fcf3e commit 25c26ffffba166e8bc4b8d0b552921404229ef47
Showing with 4 additions and 1 deletion.
  1. +3 −0 src/View/Widget/MultiCheckbox.php
  2. +1 −1 tests/TestCase/View/Widget/MultiCheckboxTest.php
@@ -153,6 +153,9 @@ protected function _renderInput($checkbox) {
'text' => $checkbox['text'],
'input' => $input,
];
if (!empty($checkbox['checked']) && empty($labelAttrs['class'])) {
$labelAttrs['class'] = 'selected';
}
$label = $this->_label->render($labelAttrs);
return $this->_templates->format('checkboxContainer', [
@@ -185,7 +185,7 @@ public function testRenderSelected() {
'id' => 'tags-id-1',
'checked' => 'checked'
]],
['label' => ['for' => 'tags-id-1']],
['label' => ['class' => 'selected', 'for' => 'tags-id-1']],
'CakePHP',
'/label',
'/div',

0 comments on commit 25c26ff

Please sign in to comment.
You can’t perform that action at this time.