fix for select with empty value

This commit is contained in:
Roland Gruber 2017-05-25 09:49:05 +02:00
parent fab16750a6
commit e6dd937f32
1 changed files with 2 additions and 2 deletions

View File

@ -1273,13 +1273,13 @@ class htmlSelect extends htmlElement {
foreach ($elements as $key => $value) {
$selected = '';
if ($this->hasDescriptiveElements) {
if (in_array($value, $this->selectedElements)) {
if (in_array($value, $this->selectedElements) || (empty($this->selectedElements) && empty($value))) {
$selected = ' selected';
}
echo "<option value=\"" . htmlspecialchars($value) . "\"$selected>" . htmlspecialchars($key) . "</option>\n";
}
else {
if (in_array($value, $this->selectedElements)) {
if (in_array($value, $this->selectedElements) || (empty($this->selectedElements) && empty($value))) {
$selected = ' selected';
}
echo "<option$selected>" . htmlspecialchars($value) . "</option>\n";