Skip to content
Snippets Groups Projects
Commit 30e7d721 authored by Jared Hancock's avatar Jared Hancock
Browse files

Fixup initial creation of properties forms for lists

parent 1e24585c
Branches
Tags
No related merge requests found
......@@ -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) {
......
......@@ -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':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment