From 9477c53b43e8d3dcff6f53e34c51cf79441fc4db Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 18 Sep 2015 10:52:03 +0200 Subject: [PATCH] NavigationConfigForm: Do not allow to choose a parent once a item is shared refs #5600 --- application/forms/Navigation/MenuItemForm.php | 9 ++++++--- application/forms/Navigation/NavigationConfigForm.php | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/application/forms/Navigation/MenuItemForm.php b/application/forms/Navigation/MenuItemForm.php index 3cc296bfe..924d313a1 100644 --- a/application/forms/Navigation/MenuItemForm.php +++ b/application/forms/Navigation/MenuItemForm.php @@ -16,8 +16,11 @@ class MenuItemForm extends NavigationItemForm public function createElements(array $formData) { parent::createElements($formData); - $this->getParent()->getElement('parent')->setDescription($this->translate( - 'The parent menu to assign this menu entry to. Select "None" to make this a main menu entry' - )); + $parentElement = $this->getParent()->getElement('parent'); + if ($parentElement !== null) { + $parentElement->setDescription($this->translate( + 'The parent menu to assign this menu entry to. Select "None" to make this a main menu entry' + )); + } } } diff --git a/application/forms/Navigation/NavigationConfigForm.php b/application/forms/Navigation/NavigationConfigForm.php index 744b7bb1b..f7aff35f2 100644 --- a/application/forms/Navigation/NavigationConfigForm.php +++ b/application/forms/Navigation/NavigationConfigForm.php @@ -431,6 +431,7 @@ class NavigationConfigForm extends ConfigForm */ public function createElements(array $formData) { + $shared = false; $itemTypes = $this->getItemTypes(); $itemType = isset($formData['type']) ? $formData['type'] : key($itemTypes); $itemForm = $this->getItemForm($itemType); @@ -466,6 +467,7 @@ class NavigationConfigForm extends ConfigForm ); if ($checked || (isset($formData['shared']) && $formData['shared'])) { + $shared = true; $this->addElement( 'text', 'users', @@ -501,7 +503,7 @@ class NavigationConfigForm extends ConfigForm ) ); - if ($itemForm->requiresParentSelection()) { + if (! $shared && $itemForm->requiresParentSelection()) { $availableParents = $this->listAvailableParents($itemType); $this->addElement( 'select',