Skip to content
Permalink
Browse files

Fix multi-checkboxes not being selected properly.

When rendering with complex options checkboxes were not being selected
correctly.

Refs #6894
  • Loading branch information...
markstory committed Jun 26, 2015
1 parent 6b6f222 commit ece39d147e1b1e6df1e1a9cf8bed2758cdbdbf1d
@@ -127,7 +127,7 @@ public function render(array $data, ContextInterface $context)
$checkbox['name'] = $data['name'];
$checkbox['escape'] = $data['escape'];
if ($this->_isSelected($key, $data['val'])) {
if ($this->_isSelected($checkbox['value'], $data['val'])) {
$checkbox['checked'] = true;
}
if ($this->_isDisabled($key, $data['disabled'])) {
@@ -97,6 +97,7 @@ public function testRenderComplex()
$input = new MultiCheckboxWidget($this->templates, $label);
$data = [
'name' => 'Tags[id]',
'val' => 2,
'options' => [
['value' => '1', 'text' => 'CakePHP', 'data-test' => 'val'],
['value' => '2', 'text' => 'Development', 'class' => 'custom'],
@@ -119,12 +120,13 @@ public function testRenderComplex()
['div' => ['class' => 'checkbox']],
['input' => [
'type' => 'checkbox',
'checked' => 'checked',
'name' => 'Tags[id][]',
'value' => 2,
'id' => 'tags-id-2',
'class' => 'custom',
]],
['label' => ['for' => 'tags-id-2']],
['label' => ['class' => 'selected', 'for' => 'tags-id-2']],
'Development',
'/label',
'/div',

0 comments on commit ece39d1

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