diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index d418afda011742afecaa6c502ce09992f88784df..cde5b24900c6b0f6c5af4b7edeb1b9bd4d059f41 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()); }