diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 45fb90e21d2e85f24aa431c8567c6fa4872c1051..424e6ebb16efd4770d817e81995f98e0ab8052b9 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 06e52d8d5611d920f06f5ffa827a3be5396d357a..668ae4f68d26a1f9ba15e7a093f26cd9cccfa80c 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':