From 070cb4bfbbf285d371b441e4344177f843ecbeb9 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 5 Mar 2014 16:48:29 -0600
Subject: [PATCH] forms: Better failsafe for __toString

This mostly helps when fields change types. If the type of the field
currently cannot convert previous data to a string (like if a short-answer
field was changed to choices), the textual representation of the PHP value
of the field data is given.
---
 include/class.dynamic_forms.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 924ad0140..6aba451e5 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -729,7 +729,8 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
     }
 
     function __toString() {
-        return $this->toString();
+        $v = $this->toString();
+        return is_string($v) ? $v : (string) $this->getValue();
     }
 }
 
-- 
GitLab