From 01e97f0e373a400917455ab7f3fe45021224ccd8 Mon Sep 17 00:00:00 2001
From: JediKev <kevin@enhancesoft.com>
Date: Tue, 26 Jun 2018 16:09:03 -0500
Subject: [PATCH] issue: Choices Field Export
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This addresses an issue where exporting a ticket with a Custom Choices
Field does not export the Custom Choice data. This is due to the
`ChoiceField::getChoice()` function that doesn’t add the correct `id` to
the `$selection` array. This updates the function to include the `id` in
the array so we can get the correct value later on.
---
 include/class.forms.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/class.forms.php b/include/class.forms.php
index 6e3e39141..8a3f5299d 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -1847,9 +1847,9 @@ class ChoiceField extends FormField {
         if ($value && is_array($value)) {
             $selection = $value;
         } elseif (isset($choices[$value]))
-            $selection[] = $choices[$value];
-        elseif ($this->get('default'))
-            $selection[] = $choices[$this->get('default')];
+            $selection[$value] = $choices[$value];
+        elseif (($v=$this->get('default')) && isset($choices[$v]))
+            $selection[$v] = $choices[$v];
 
         return $selection;
     }
-- 
GitLab