BUFGFIX: Prevent selection of self as parent (see #5106)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99732 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Luke Hudson 2010-02-23 21:58:05 +00:00 committed by Sam Minnee
parent 4a09702d63
commit d6b219957a

View File

@ -1722,7 +1722,7 @@ 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')),
@ -1768,6 +1768,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
)
//new NamedLabelField("Status", $message, "pageStatusMessage", true)
);
/*
* 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',