diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php
index 9fbdf6e8ba6..a134d27bd50 100644
--- a/framework/helpers/BaseHtml.php
+++ b/framework/helpers/BaseHtml.php
@@ -1930,13 +1930,12 @@ public static function renderSelectOptions($selection, $items, &$tagOptions = []
if ($selection !== null) {
if (ArrayHelper::isTraversable($selection)) {
$selected = ArrayHelper::isIn((string)$key, $selection, $strict);
+ } elseif (is_object($selection) && property_exists($selection, 'value')) {
+ $selected = $selection->value == $key;
} elseif ($key === '' || $selection === '') {
$selected = $selection === $key;
- } elseif ($strict) {
- $selected = !strcmp((string)$key, (string)$selection);
} else {
- $selected = is_object($selection) && property_exists($selection, 'value') ?
- $selection->value == $key : $selection == $key;
+ $selected = $strict ? !strcmp((string)$key, (string)$selection) : $selection == $key;
}
}