mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Make choose_from_menu behave correctly in the obscure case where an array
contains a zero key and the "selected" variable is a string. Argh.
This commit is contained in:
parent
63f6f13776
commit
97e28cc66d
@ -652,7 +652,9 @@ function choose_from_menu ($options, $name, $selected='', $nothing='choose', $sc
|
||||
if (!empty($options)) {
|
||||
foreach ($options as $value => $label) {
|
||||
$output .= ' <option value="'. $value .'"';
|
||||
if ($value == $selected) {
|
||||
// The gettype() calls are there because otherwise a numeric zero key is a match for any string value
|
||||
// As gettype() is possibly expensive, only run the check if the simple equality holds true
|
||||
if ($value == $selected && gettype($value) == gettype($selected)) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
if ($label === '') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user