diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index 525cb4d..8f03f10 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -35,6 +35,7 @@ public function form(array $form, array &$form_state) { '#default_value' => $menu->id(), '#maxlength' => MENU_MAX_MENU_NAME_LENGTH_UI, '#description' => t('A unique name to construct the URL for the menu. It must only contain lowercase letters, numbers and hyphens.'), + '#field_prefix' => $menu->isNew() ? 'menu-' : '', '#machine_name' => array( 'exists' => 'menu_edit_menu_name_exists', 'source' => array('label'), @@ -118,10 +119,12 @@ protected function actions(array $form, array &$form_state) { * {@inheritdoc} */ public function validate(array $form, array &$form_state) { + if ($this->entity->isNew()) { // The machine name is validated automatically, we only need to add the // 'menu-' prefix here. $form_state['values']['id'] = 'menu-' . $form_state['values']['id']; } + } /** * Submit handler to update the bundle for the default language configuration. diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php index 94421e4..63bfe57 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuLanguageTest.php @@ -68,6 +68,8 @@ function testMenuLanguage() { $this->drupalPost('admin/structure/menu/add', $edit, t('Save')); // Check that the language settings were saved. + // The menu name should have been prefixed. + $menu_name = 'menu-' . $menu_name; $this->assertEqual(entity_load('menu', $menu_name)->langcode, $edit['langcode']); $language_settings = language_get_default_configuration('menu_link', $menu_name); $this->assertEqual($language_settings['langcode'], 'bb'); @@ -91,7 +93,11 @@ function testMenuLanguage() { // Check the link was added with the correct menu link default language. $menu_links = entity_load_multiple_by_properties('menu_link', array('link_title' => $link_title)); $menu_link = reset($menu_links); - $this->assertMenuLink($menu_link->id(), array('menu_name' => $menu_name, 'link_path' => $link_path, 'langcode' => 'bb')); + $this->assertMenuLink($menu_link->id(), array( + 'menu_name' => $menu_name, + 'link_path' => $link_path, + 'langcode' => 'bb', + )); // Edit menu link default, changing it to cc. $edit = array(