From: Robert Kaiser Date: Fri, 12 Apr 2024 23:33:47 +0000 (+0200) Subject: make sure that values like '0' are valid in select options X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=commitdiff_plain make sure that values like '0' are valid in select options --- diff --git a/classes/document.php-class b/classes/document.php-class index ebde6ec..c2f0fcf 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -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; }