diff --git a/_test/tests/inc/form/dropdownelement.test.php b/_test/tests/inc/form/dropdownelement.test.php
index 3aa0f16e4be1d10dfae4e1e7c6e223dd4e570c64..5f6b35e7521d450f3c8f9caab1e2f7c719aab670 100644
--- a/_test/tests/inc/form/dropdownelement.test.php
+++ b/_test/tests/inc/form/dropdownelement.test.php
@@ -129,6 +129,21 @@ class form_dropdownelement_test extends DokuWikiTest {
         $this->assertEquals('label of third option', $selected->text());
     }
 
+    /**
+     * Prevent double select that might occur because `'Auto' == 0` is true
+     */
+    public function test_doubleselect() {
+        $form = new Form\Form();
+        $form->addDropdown('foo', ['Auto', 0, 1]);
+
+        $html = $form->toHTML();
+
+        $pq = phpQuery::newDocumentXHTML($html);
+        $selected = $pq->find('option[selected=selected]');
+        $this->assertEquals(1, $selected->length);
+        $this->assertEquals('Auto', $selected->text());
+    }
+
     /**
      * Ensure that there is always only a single one selected option
      */
diff --git a/inc/Form/OptGroup.php b/inc/Form/OptGroup.php
index dbc0a115c56cde5e25b791d6473ab233e5dc0f12..791f0b3f6616885e198afed6e0d2216744b6cd40 100644
--- a/inc/Form/OptGroup.php
+++ b/inc/Form/OptGroup.php
@@ -88,7 +88,7 @@ class OptGroup extends Element {
     protected function renderOptions() {
         $html = '';
         foreach($this->options as $key => $val) {
-            $selected = ($key == $this->value) ? ' selected="selected"' : '';
+            $selected = ((string)$key === (string)$this->value) ? ' selected="selected"' : '';
             $attrs = '';
             if (!empty($val['attrs']) && is_array($val['attrs'])) {
                 $attrs = buildAttributes($val['attrs']);