make sure that values like '0' are valid in select options
authorRobert Kaiser <kairo@kairo.at>
Fri, 12 Apr 2024 23:33:47 +0000 (01:33 +0200)
committerRobert Kaiser <kairo@kairo.at>
Fri, 12 Apr 2024 23:33:47 +0000 (01:33 +0200)
classes/document.php-class

index ebde6ec965f8ec52f16bbfaa6f40610519351e7e..c2f0fcfe0d9107d7baf897774dd79bda2d2f44f7 100755 (executable)
@@ -687,10 +687,12 @@ class ExtendedDocument extends DOMDocument {
 
   public function createElementOption($key, $desc, $selected = false) {
     $option = $this->createElement('option', $desc);
-    if ($key) {
+    if (is_numeric($key) || is_string($key)) {
       $option->setAttribute('value', $key);
     }
-    if ($selected) { $option->setAttribute('selected', ''); }
+    if ($selected) {
+      $option->setAttribute('selected', '');
+    }
     return $option;
   }