From 1f5654ed19de64543f44a41e2cf0e7cd046f4e21 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 14 Apr 2010 05:36:33 +0000 Subject: [PATCH] BUFGFIX: Prevent selection of self as parent (see #5106) (from r99732) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102876 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index b7757dc8d..d30b773b4 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1754,9 +1754,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid "root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"), "subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page (choose below)"), )), - new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree') + $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree') ), - new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')), /*, new TreeMultiselectField("MultipleParents", "Page appears within", "SiteTree")*/ @@ -1800,6 +1799,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid ) ) ); + + + /* + * This filter ensures that the ParentID dropdown selection does not show this node, + * or its descendents, as this causes vanishing bugs. + */ + $parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};")); if ($virtualPagesTable->TotalCount()) { $rootTab->push($tabVirtualPages = new Tab('VirtualPages',