diff --git a/modules/menu/menu.module b/modules/menu/menu.module index 3edf158..9ead434 100644 --- a/modules/menu/menu.module +++ b/modules/menu/menu.module @@ -598,8 +598,9 @@ function menu_form_node_form_alter(&$form, $form_state) { // @todo This must be handled in a #process handler. $type = $form['#node']->type; $options = menu_parent_options(menu_get_menus(), $type); - // If no possible parent menu items were found, there is nothing to display. - if (empty($options)) { + // If no possible parent menu items were found and no menu link exists, + // there is nothing to display. + if (empty($options) && empty($form['#node']->menu['mlid'])) { return; } $link = $form['#node']->menu; @@ -653,9 +654,12 @@ function menu_form_node_form_alter(&$form, $form_state) { ); $default = ($link['mlid'] ? $link['menu_name'] . ':' . $link['plid'] : variable_get('menu_parent_' . $type, 'main-menu:0')); - // @todo This will fail with the new selective menus per content type. + + // If the item is in a menu that is not permitted for this content type, + // allow it to stay there. if (!isset($options[$default])) { - $default = 'navigation:0'; + $all_options = menu_parent_options(menu_get_menus(), $link); + $options[$default] = $all_options[$default]; } $form['menu']['link']['parent'] = array( '#type' => 'select', diff --git a/modules/menu/menu.test b/modules/menu/menu.test index 6c11da6..f4c6d2b 100644 --- a/modules/menu/menu.test +++ b/modules/menu/menu.test @@ -664,5 +664,17 @@ class MenuNodeTestCase extends DrupalWebTestCase { // Assert that there is no link for the node. $this->drupalGet(''); $this->assertNoLink($node_title); + + // Add a menu link to the Management menu. + $edit = array( + 'link_path' => 'node/' . $node->nid, + 'link_title' => $node_title, + 'parent' => 'management:0', + ); + $this->drupalPost("admin/structure/menu/manage/management/add", $edit, t('Save')); + + // Assert that Management is selected on the node/$nid/edit page, even though the Management menu is not selected for the node type. + $this->drupalGet('node/' . $node->nid . '/edit'); + $this->assertRaw('