mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
19324 dropdownlist selection for boolean attributes (#19331)
* Fix #19324 by allowing for direct comparison * Invert meaning of strict * Remove WinterSilence from authors list * Fix improper implementation of strict checks * Add test for renderSelectOptions * Partially revert 'Fix improper implementation of strict checks' * Add additional tests for strict * Revert 'Fix improper implementation of strict checks' * Add failing test for demonstration * Comment out demonstration test * Update framework/CHANGELOG.md Co-authored-by: Bizley <pawel@positive.codes> Co-authored-by: Bizley <pawel@positive.codes>
This commit is contained in:
@ -1914,7 +1914,7 @@ class BaseHtml
|
||||
$attrs['value'] = (string) $key;
|
||||
if (!array_key_exists('selected', $attrs)) {
|
||||
$attrs['selected'] = $selection !== null &&
|
||||
(!ArrayHelper::isTraversable($selection) && !strcmp($key, $selection)
|
||||
(!ArrayHelper::isTraversable($selection) && ($strict ? !strcmp($key, $selection) : $selection == $key)
|
||||
|| ArrayHelper::isTraversable($selection) && ArrayHelper::isIn((string)$key, $selection, $strict));
|
||||
}
|
||||
$text = $encode ? static::encode($value) : $value;
|
||||
|
Reference in New Issue
Block a user