From 16c22fb795e4dc06585a17ba8946efb303f4672d Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Thu, 21 Nov 2024 09:43:15 +0100 Subject: [PATCH] Make own menuItem unselectable when editing --- .../files/lib/acp/form/MenuItemAddForm.class.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php index 934dd61162..e3cc667d7c 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php @@ -5,6 +5,7 @@ namespace wcf\acp\form; use wcf\data\IStorableObject; use wcf\data\menu\item\MenuItem; use wcf\data\menu\item\MenuItemAction; +use wcf\data\menu\item\MenuItemNode; use wcf\data\menu\item\MenuItemNodeTree; use wcf\data\menu\Menu; use wcf\data\page\Page; @@ -108,7 +109,20 @@ class MenuItemAddForm extends AbstractFormBuilderForm ->appendChildren([ SelectFormField::create('parentItemID') ->label('wcf.acp.menu.item.parentItem') - ->options($this->menuItemNodeList, true), + ->options(function () { + $result = []; + foreach ($this->menuItemNodeList as $menuItem) { + \assert($menuItem instanceof MenuItemNode); + + $result[] = [ + 'depth' => $menuItem->getDepth(), + 'isSelectable' => $menuItem->itemID !== $this->formObject?->itemID, + 'label' => $menuItem->getTitle(), + 'value' => $menuItem->getObjectID(), + ]; + } + return $result; + }, true), TitleFormField::create() ->i18n() ->required() -- 2.20.1