From eacf8a65569908440a3b7032a2412116b16383c3 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 23 Oct 2014 16:37:15 -0500
Subject: [PATCH] forms: Fix interpretation of custom list data

Prior to osTicket v1.9.4, drop down lists only allowed for a single entry.
After upgrading to 1.9.4 the database data for drop downs changed to allow
for multiple entries. However, the old data format was not properly handled
by the SelectionField::to_php() method which handled interpreting and
upgrading the database data.
---
 include/class.dynamic_forms.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 11318d436..3a4457177 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -1127,7 +1127,9 @@ class SelectionField extends FormField {
         if (!is_array($value)) {
             $choices = $this->getChoices();
             if (isset($choices[$value]))
-                $value = $choices[$value];
+                $value = array($value => $choices[$value]);
+            elseif ($id && isset($choices[$id]))
+                $value = array($id => $choices[$id]);
         }
         // Don't set the ID here as multiselect prevents using exactly one
         // ID value. Instead, stick with the JSON value only.
-- 
GitLab