From 8ee679ac6d87026e6232a250fd0c7671d9b8289d Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 15 May 2015 16:33:18 -0500 Subject: [PATCH] custom data: Fix custom data on separate form for new ticket --- include/class.dynamic_forms.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index d418afda0..cde5b2490 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1053,6 +1053,10 @@ class DynamicFormEntry extends VerySimpleModel { } function setSource($source) { $this->_source = $source; + // Ensure the field is connected to this data source + foreach ($this->getFields() as $F) + if (!$F->getForm()) + $F->setForm($this); } function getField($name) { @@ -1214,7 +1218,6 @@ class DynamicFormEntry extends VerySimpleModel { if (count($this->dirty)) $this->set('updated', new SqlFunction('NOW')); - $wasnew = $this->__new__; if (!parent::save($refetch || count($this->dirty))) return false; @@ -1233,11 +1236,6 @@ class DynamicFormEntry extends VerySimpleModel { // entry-id if necessary $a->entry = $this; - // If this is a new entry, then ensure that the field is - // connected to the data associated with this entry - if ($wasnew) - $field->setForm($this); - try { $val = $field->to_database($field->getClean()); } -- GitLab