Browse Source

Fixes #14230: Fixed `itemsOptions` ignored in `checkBoxList`

tags/2.0.16
Evgeniy Moiseenko 6 years ago committed by Alexander Makarov
parent
commit
a8bfe8bbe6
  1. 1
      framework/CHANGELOG.md
  2. 4
      framework/helpers/BaseHtml.php
  3. 11
      tests/framework/helpers/HtmlTest.php

1
framework/CHANGELOG.md

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.16 under development
------------------------
- Bug #14230: Fixed `itemsOptions` ignored in `checkBoxList` (s1lver)
- Bug #14368: Added `role` attribute for active radio list (s1lver)
- Bug #16680: Fixed ActiveField 'text' input with maxlength (s1lver)
- Bug #5341: HasMany via two relations (shirase, cebe)

4
framework/helpers/BaseHtml.php

@ -958,10 +958,10 @@ class BaseHtml
if ($formatter !== null) {
$lines[] = call_user_func($formatter, $index, $label, $name, $checked, $value);
} else {
$lines[] = static::checkbox($name, $checked, array_merge($itemOptions, [
$lines[] = static::checkbox($name, $checked, array_merge([
'value' => $value,
'label' => $encode ? static::encode($label) : $label,
]));
], $itemOptions));
}
$index++;
}

11
tests/framework/helpers/HtmlTest.php

@ -714,6 +714,17 @@ EOD;
EOD;
$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', ['1', 'value3'], $this->getDataItems3()));
$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', new \ArrayObject(['1', 'value3']), $this->getDataItems3()));
$expected = <<<'EOD'
<div><label><input type="checkbox" name="test[]" value="0"> Test Label</label>
<label><input type="checkbox" name="test[]" value="0"> Test Label</label></div>
EOD;
$this->assertEqualsWithoutLE($expected, Html::checkboxList('test', null, $this->getDataItems(), [
'itemOptions' => [
'value' => 0,
'label' => 'Test Label'
]
]));
}
public function testRadioList()

Loading…
Cancel
Save