From b767ae192fcc3346ac2b27b427d5b5db460183c9 Mon Sep 17 00:00:00 2001 From: Felix Eggmann Date: Wed, 5 Feb 2020 19:02:01 +0100 Subject: [PATCH] fix(treeView): remove relations when deleting an element --- src/TreeView.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/TreeView.php b/src/TreeView.php index 23aa940..33f44de 100644 --- a/src/TreeView.php +++ b/src/TreeView.php @@ -404,6 +404,13 @@ public function delete($request) // Close the element in case it's open to avoid errors $this->closeItem($path); + // let's remove all relations + $this->getItems()->removeByID($itemId); + foreach ($parents as $parentId) { + $parent = PageElement::get()->byID($parentId); + if ($parent) $parent->Children()->removeByID($itemId); + } + // Delete the element $item->delete();