Skip to content

Commit

Permalink
Fix yiisoft#19324 by allowing for direct comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
adnandautovic committed Mar 30, 2022
1 parent f6d3283 commit 8565baa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Yii Framework 2 Change Log
- Enh #19304: Add filtering validator `yii\validators\TrimValidator` (WinterSilence)
- Enh #19309: Optimize `yii\base\Model::attributes()` (WinterSilence)
- Bug #19322: Revert force setting value to empty string in case it's `null` in `yii\validators\FilterValidator::validateAttribute()` (bizley)
- Bug #19324: Fix yii\helpers\BaseHtml::renderSelectOptions() giving wrong selection for boolean attributes (adnandautovic)
- Bug #19329: Fix `yii\web\GroupUrlRule` to properly normalize prefix (bizley)


Expand Down
2 changes: 1 addition & 1 deletion framework/helpers/BaseHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ public static function renderSelectOptions($selection, $items, &$tagOptions = []
$attrs['value'] = (string) $key;
if (!array_key_exists('selected', $attrs)) {
$attrs['selected'] = $selection !== null &&
(!ArrayHelper::isTraversable($selection) && !strcmp($key, $selection)
(!ArrayHelper::isTraversable($selection) && ($strict ? $selection == $key : !strcmp($key, $selection))
|| ArrayHelper::isTraversable($selection) && ArrayHelper::isIn((string)$key, $selection, $strict));
}
$text = $encode ? static::encode($value) : $value;
Expand Down

0 comments on commit 8565baa

Please sign in to comment.