From c077dbd15a7b592bacf82eb2b8c1ab8a6c5b55e0 Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@netways.de>
Date: Fri, 18 Sep 2015 16:00:33 +0200
Subject: [PATCH] NavigationConfigForm: Update a parent's name on all childrens
 as well

refs #5600
---
 application/forms/Navigation/NavigationConfigForm.php | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/application/forms/Navigation/NavigationConfigForm.php b/application/forms/Navigation/NavigationConfigForm.php
index 661e66a64..e36f66b50 100644
--- a/application/forms/Navigation/NavigationConfigForm.php
+++ b/application/forms/Navigation/NavigationConfigForm.php
@@ -349,15 +349,26 @@ class NavigationConfigForm extends ConfigForm
             $shared = true;
         }
 
+        $oldName = null;
         if (isset($data['name'])) {
             if ($data['name'] !== $name) {
                 $config->removeSection($name);
+                $oldName = $name;
                 $name = $data['name'];
             }
 
             unset($data['name']);
         }
 
+        if ($oldName) {
+            // Update the parent name on all direct children
+            foreach ($config as $sectionConfig) {
+                if ($sectionConfig->parent === $oldName) {
+                    $sectionConfig->parent = $name;
+                }
+            }
+        }
+
         $itemConfig->merge($data);
         foreach ($itemConfig->toArray() as $k => $v) {
             if ($v === null) {