Skip to content
Snippets Groups Projects
Commit afc19371 authored by Peter Rotich's avatar Peter Rotich Committed by Peter Rotich
Browse files

forms: Add ability to delete properties form

This adds ability to delete properties on list deletion
parent 60300f09
No related branches found
No related tags found
No related merge requests found
......@@ -189,9 +189,11 @@ class DynamicForm extends VerySimpleModel {
}
function delete() {
if (!$this->isDeletable())
return false;
// Soft Delete: Mark the form as deleted.
$this->setFlag(self::FLAG_DELETED);
return $this->save();
}
......
......@@ -355,11 +355,20 @@ class DynamicList extends VerySimpleModel implements CustomList {
function delete() {
$fields = DynamicFormField::objects()->filter(array(
'type'=>'list-'.$this->id))->count();
if ($fields == 0)
return parent::delete();
else
// Refuse to delete lists that are in use by fields
// Refuse to delete lists that are in use by fields
if ($fields != 0)
return false;
if (!parent::delete())
return false;
if (($form = $this->getForm(false))) {
$form->delete(false);
$form->fields->delete();
}
return true;
}
private function createForm() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment