Fix code warning if no value is selected in htmlSelect

This commit is contained in:
Isaac Connor 2020-09-03 18:21:38 -04:00
parent 47971bb8f5
commit 240f4ceabd
1 changed files with 3 additions and 2 deletions

View File

@ -520,8 +520,9 @@ function htmlOptions($options, $values) {
} else {
$text = $option;
}
$selected = is_array($values) ? in_array($value, $values) : !strcmp($value, $values);
$has_selected = (!$has_selected) && $selected;
$selected = is_array($values) ? in_array($value, $values) : (!strcmp($value, $values));
if ( !$has_selected )
$has_selected = $selected;
$options_html .= '<option value="'.htmlspecialchars($value, ENT_COMPAT | ENT_HTML401, ini_get('default_charset'), false).'"'.
($selected?' selected="selected"':'').