Skip to content

Commit

Permalink
fix(treeView): remove relations when deleting an element
Browse files Browse the repository at this point in the history
  • Loading branch information
flxqr2 committed Feb 5, 2020
1 parent 0c33dfe commit b767ae1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit b767ae1

Please sign in to comment.