Fix preselection when key is '0'

This commit is contained in:
Laurent Destailleur 2019-02-26 12:20:22 +01:00
parent 528bfca690
commit 5bcce53e40

View File

@ -6167,7 +6167,6 @@ class Form
} }
// Try also magic suggest // Try also magic suggest
$out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss?' '.$morecss:'').'" multiple name="'.$htmlname.'[]"'.($moreattrib?' '.$moreattrib:'').($width?' style="width: '.(preg_match('/%/', $width)?$width:$width.'px').'"':'').'>'."\n"; $out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss?' '.$morecss:'').'" multiple name="'.$htmlname.'[]"'.($moreattrib?' '.$moreattrib:'').($width?' style="width: '.(preg_match('/%/', $width)?$width:$width.'px').'"':'').'>'."\n";
if (is_array($array) && ! empty($array)) if (is_array($array) && ! empty($array))
{ {
@ -6178,7 +6177,7 @@ class Form
foreach ($array as $key => $value) foreach ($array as $key => $value)
{ {
$out.= '<option value="'.$key.'"'; $out.= '<option value="'.$key.'"';
if (is_array($selected) && ! empty($selected) && in_array($key, $selected) && ((string) $key != '')) if (is_array($selected) && ! empty($selected) && in_array((string) $key, $selected) && ((string) $key != ''))
{ {
$out.= ' selected'; $out.= ' selected';
} }