From 30e7d721ad01fc8cd3ec2500725a7b2bf193808e Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 31 Mar 2014 10:56:58 -0500 Subject: [PATCH] Fixup initial creation of properties forms for lists --- include/class.dynamic_forms.php | 4 ++-- scp/lists.php | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 45fb90e21..424e6ebb1 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -918,7 +918,8 @@ class DynamicListItem extends VerySimpleModel { function setConfiguration(&$errors=array()) { $config = array(); foreach ($this->getConfigurationForm()->getFields() as $field) { - $config[$field->get('id')] = $field->to_database($field->getClean()); + $val = $field->to_database($field->getClean()); + $config[$field->get('id')] = is_array($val) ? $val[1] : $val; $errors = array_merge($errors, $field->errors()); } if (count($errors) === 0) @@ -935,7 +936,6 @@ class DynamicListItem extends VerySimpleModel { return $this->_form; } - function getVar($name) { $config = $this->getConfiguration(); foreach ($this->getConfigurationForm()->getFields() as $field) { diff --git a/scp/lists.php b/scp/lists.php index 06e52d8d5..668ae4f68 100644 --- a/scp/lists.php +++ b/scp/lists.php @@ -41,6 +41,13 @@ if($_POST) { } $names = array(); + if (!$form) { + $form = DynamicForm::create(array( + 'type'=>'L'.$_REQUEST['id'], + 'title'=>$_POST['name'] . ' Properties' + )); + $form->save(true); + } foreach ($form->getDynamicFields() as $field) { $id = $field->get('id'); if ($_POST["delete-$id"] == 'on' && $field->isDeletable()) { @@ -84,12 +91,20 @@ if($_POST) { 'sort_mode'=>$_POST['sort_mode'], 'notes'=>$_POST['notes'])); + $form = DynamicForm::create(array( + 'title'=>$_POST['name'] . ' Properties' + )); + if ($errors) $errors['err'] = 'Unable to create custom list. Correct any error(s) below and try again.'; - elseif ($list->save(true)) - $msg = 'Custom list added successfully'; + elseif (!$list->save(true)) + $errors['err'] = 'Unable to create custom list: Unknown internal error'; + + $form->set('type', 'L'.$list->get('id')); + if (!$errors && !$form->save(true)) + $errors['err'] = 'Unable to create properties for custom list: Unknown internal error'; else - $errors['err'] = 'Unable to create custom list. Unknown internal error'; + $msg = 'Custom list added successfully'; break; case 'mass_process': -- GitLab