From b0fa4269c0e8986930f5a480bc4eaaf813ffbaeb Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 9 Oct 2014 16:31:13 -0500 Subject: [PATCH] forms: Fix warnings when creating a new custom form --- include/class.dynamic_forms.php | 4 +++- scp/forms.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 19ac4bb9f..2f1c3a9e5 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 5bf9415e9..3b7e6af04 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()) { -- GitLab