From a8bfe8bbe67fb7228c7b3ab5fac52c467c1224d0 Mon Sep 17 00:00:00 2001 From: Evgeniy Moiseenko Date: Wed, 19 Sep 2018 17:39:21 +0300 Subject: [PATCH] Fixes #14230: Fixed `itemsOptions` ignored in `checkBoxList` --- framework/CHANGELOG.md | 1 + framework/helpers/BaseHtml.php | 4 ++-- tests/framework/helpers/HtmlTest.php | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index d868083..79ded8b 100644 --- a/framework/CHANGELOG.md +++ b/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) diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 7e27158..e89abbe 100644 --- a/framework/helpers/BaseHtml.php +++ b/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++; } diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 2d21642..b46fe22 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/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' +
+
+EOD; + $this->assertEqualsWithoutLE($expected, Html::checkboxList('test', null, $this->getDataItems(), [ + 'itemOptions' => [ + 'value' => 0, + 'label' => 'Test Label' + ] + ])); } public function testRadioList()