From eb8858e734de7cb67c307e7c67756391450f26bb Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 10 Mar 2015 11:20:04 -0500
Subject: [PATCH] oops: Avoid handling fields without answers in save

---
 include/class.dynamic_forms.php | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 01979c758..3d73b862d 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -930,12 +930,16 @@ class DynamicFormEntry extends VerySimpleModel {
         }
     }
 
-    function save() {
+    function save($refetch=false) {
         if (count($this->dirty))
             $this->set('updated', new SqlFunction('NOW'));
-        parent::save();
+        if (!parent::save($refetch || count($this->dirty)))
+            return false;
+
         foreach ($this->getFields() as $field) {
-            $a = $field->getAnswer();
+            if (!($a = $field->getAnswer()))
+                continue;
+
             if ($this->object_type == 'U'
                     && in_array($field->get('name'), array('name','email')))
                 continue;
-- 
GitLab