NavigationConfigForm: Do not allow to choose a parent once a item is shared

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-18 10:52:03 +02:00
parent 4b7fbdfa1f
commit 9477c53b43
2 changed files with 9 additions and 4 deletions

View File

@ -16,8 +16,11 @@ class MenuItemForm extends NavigationItemForm
public function createElements(array $formData) public function createElements(array $formData)
{ {
parent::createElements($formData); parent::createElements($formData);
$this->getParent()->getElement('parent')->setDescription($this->translate( $parentElement = $this->getParent()->getElement('parent');
'The parent menu to assign this menu entry to. Select "None" to make this a main menu entry' 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'
));
}
} }
} }

View File

@ -431,6 +431,7 @@ class NavigationConfigForm extends ConfigForm
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
$shared = false;
$itemTypes = $this->getItemTypes(); $itemTypes = $this->getItemTypes();
$itemType = isset($formData['type']) ? $formData['type'] : key($itemTypes); $itemType = isset($formData['type']) ? $formData['type'] : key($itemTypes);
$itemForm = $this->getItemForm($itemType); $itemForm = $this->getItemForm($itemType);
@ -466,6 +467,7 @@ class NavigationConfigForm extends ConfigForm
); );
if ($checked || (isset($formData['shared']) && $formData['shared'])) { if ($checked || (isset($formData['shared']) && $formData['shared'])) {
$shared = true;
$this->addElement( $this->addElement(
'text', 'text',
'users', 'users',
@ -501,7 +503,7 @@ class NavigationConfigForm extends ConfigForm
) )
); );
if ($itemForm->requiresParentSelection()) { if (! $shared && $itemForm->requiresParentSelection()) {
$availableParents = $this->listAvailableParents($itemType); $availableParents = $this->listAvailableParents($itemType);
$this->addElement( $this->addElement(
'select', 'select',