From 1b26d16d86d6a898466211861adc1dff2286da2b Mon Sep 17 00:00:00 2001
From: Michael Grosse <grosse@cosmocode.de>
Date: Tue, 17 Jan 2017 11:17:55 +0100
Subject: [PATCH] Allow select-options as arrays with numeric keys

The problem this is solving is that PHP does not allow for array-keys to
be strings of ints. It always converts them to actual ints. This caused
a problem when trying to use complex array-options with integers as
keys.
---
 inc/Form/OptGroup.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/inc/Form/OptGroup.php b/inc/Form/OptGroup.php
index 66e29f974..fa0b516db 100644
--- a/inc/Form/OptGroup.php
+++ b/inc/Form/OptGroup.php
@@ -50,13 +50,13 @@ class OptGroup extends Element {
         if(!is_array($options)) throw new \InvalidArgumentException('Options have to be an array');
         $this->options = array();
         foreach($options as $key => $val) {
-            if(is_int($key)) {
-                $this->options[$val] = array('label' => (string) $val);
-            } elseif (!is_array($val)) {
-                $this->options[$key] = array('label' => (string) $val);
-            } else {
+            if (is_array($val)) {
                 if (!key_exists('label', $val)) throw new \InvalidArgumentException('If option is given as array, it has to have a "label"-key!');
                 $this->options[$key] = $val;
+            } elseif(is_int($key)) {
+                $this->options[$val] = array('label' => (string) $val);
+            } else {
+                $this->options[$key] = array('label' => (string) $val);
             }
         }
         return $this;
-- 
GitLab