From 376234676eb83dbfcfeb8b72b0693a129484ca4d Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 10 Oct 2013 21:04:40 +0000
Subject: [PATCH] Finish display of custom field content in tickets

---
 include/class.dynamic_forms.php |  4 ++++
 include/class.ticket.php        | 14 +++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 553a3da2f..92863db2f 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -566,6 +566,10 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
     function toString() {
         return $this->getField()->toString($this->getValue());
     }
+
+    function __toString() {
+        return $this->toString();
+    }
 }
 
 /**
diff --git a/include/class.ticket.php b/include/class.ticket.php
index f4dd51c0d..596254830 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -109,8 +109,8 @@ class Ticket {
         if (!$this->_answers) {
             foreach (DynamicFormEntry::forTicket($this->getId(), true) as $form)
                 foreach ($form->getAnswers() as $answer)
-                    $this->_answers[$answer->getField()->get('name')] =
-                        $answer->getValue();
+                    $this->_answers[$answer->getField()->get('name')]
+                        = $answer;
         }
     }
 
@@ -290,13 +290,13 @@ class Ticket {
     function getPriorityId() {
         global $cfg;
 
-        if ($a = $this->_answers['priority'])
+        if ($a = $this->_answers['priority']->getValue())
             return $a->getId();
         return $cfg->getDefaultPriorityId();
     }
 
     function getPriority() {
-        if ($a = $this->_answers['priority'])
+        if ($a = $this->_answers['priority']->getValue())
             return $a->getDesc();
         return '...ummm...';
     }
@@ -1095,9 +1095,9 @@ class Ticket {
                 break;
             default:
                 if (isset($this->_answers[$tag]))
-                    # TODO: Use DynamicField to format the value, also,
-                    # private field data should never go external, via
-                    # email, for instance
+                    // The answer object is retrieved here which will
+                    // automatically invoke the toString() method when the
+                    // answer is coerced into text
                     return $this->_answers[$tag];
         }
 
-- 
GitLab