From 7d6f3669c270f20b3f95d0ce8a43535b7550566a Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 11 Oct 2013 18:53:47 +0000
Subject: [PATCH] Fix custom fields in email templates

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

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 92863db2f..55020e192 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -567,6 +567,10 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
         return $this->getField()->toString($this->getValue());
     }
 
+    function asVar() {
+        return $this->toString();
+    }
+
     function __toString() {
         return $this->toString();
     }
diff --git a/include/class.ticket.php b/include/class.ticket.php
index eab0ead26..3a5a63949 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -221,7 +221,7 @@ class Ticket {
     }
 
     function getSubject() {
-        return $this->_answers['subject'];
+        return (string) $this->_answers['subject'];
     }
 
     /* Help topic title  - NOT object -> $topic */
@@ -1098,7 +1098,7 @@ class Ticket {
                     // The answer object is retrieved here which will
                     // automatically invoke the toString() method when the
                     // answer is coerced into text
-                    return $this->_answers[$tag];
+                    return (string)$this->_answers[$tag];
         }
 
         return false;
@@ -2049,6 +2049,7 @@ class Ticket {
         // Save the (common) dynamic form
         $form->setTicketId($id);
         $form->save();
+        $ticket->loadDynamicData();
 
         $dept = $ticket->getDept();
 
-- 
GitLab