diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 19ac4bb9fc4caede3b42a6150091bd843ec042b0..2f1c3a9e591884f71401fce6f14f7a72fe855f03 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -62,7 +62,9 @@ class DynamicForm extends VerySimpleModel { } function getDynamicFields() { - if (!$this->_dfields && isset($this->id)) { + if (!isset($this->id)) + return array(); + elseif (!$this->_dfields) { $this->_dfields = DynamicFormField::objects() ->filter(array('form_id'=>$this->id)) ->all(); diff --git a/scp/forms.php b/scp/forms.php index 5bf9415e98e5b6042c1870364d0cb18833489518..3b7e6af04e7f137af5732a6d7866fb169fd2a495 100644 --- a/scp/forms.php +++ b/scp/forms.php @@ -11,6 +11,7 @@ if($_POST) { $required = array('title'); $max_sort = 0; $form_fields = array(); + $names = array(); switch(strtolower($_POST['do'])) { case 'update': foreach ($fields as $f) @@ -20,7 +21,6 @@ if($_POST) { elseif (isset($_POST[$f])) $form->set($f, $_POST[$f]); $form->save(true); - $names = array(); foreach ($form->getDynamicFields() as $field) { $id = $field->get('id'); if ($_POST["delete-$id"] == 'on' && $field->isDeletable()) {