diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 191dbf3..6ab59c3 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -334,7 +334,12 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { '#default_value' => $defaults['weight'], '#description' => t('Menu links with lower weights are displayed before links with higher weights.'), ); - $form['actions']['submit']['#submit'][] = 'menu_ui_form_node_form_submit'; + + foreach (array_keys($form['actions']) as $action) { + if (isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] == 'submit') { + $form['actions'][$action]['#submit'][] = 'menu_ui_form_node_form_submit'; + } + } } /** diff --git a/core/modules/menu_ui/src/Tests/MenuNodeTest.php b/core/modules/menu_ui/src/Tests/MenuNodeTest.php index ce234fc..6d0bc97 100644 --- a/core/modules/menu_ui/src/Tests/MenuNodeTest.php +++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php @@ -34,6 +34,7 @@ protected function setUp() { $this->drupalLogin($this->drupalCreateUser(array( 'access administration pages', 'administer content types', + 'administer nodes', 'administer menu', 'create page content', 'edit any page content', @@ -60,7 +61,7 @@ function testMenuNodeFormWidget() { 'title[0][value]' => $node_title, 'body[0][value]' => $this->randomString(), ); - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle($node_title); $this->assertEqual($node->getTitle(), $edit['title[0][value]']); @@ -89,7 +90,7 @@ function testMenuNodeFormWidget() { 'title[0][value]' => $node_title, 'body[0][value]' => $this->randomString(), ); - $this->drupalPostForm('node/add/page', $edit, t('Save')); + $this->drupalPostForm('node/add/page', $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle($node_title); // Assert that there is no link for the node. $this->drupalGet('test-page'); @@ -99,7 +100,7 @@ function testMenuNodeFormWidget() { $edit = array( 'menu[enabled]' => 1, ); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); // Assert that there is no link for the node. $this->drupalGet('test-page'); $this->assertNoLink($node_title); @@ -110,7 +111,7 @@ function testMenuNodeFormWidget() { 'menu[title]' => $node_title, 'menu[weight]' => 17, ); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); // Assert that the link exists. $this->drupalGet('test-page'); $this->assertLink($node_title); @@ -122,7 +123,7 @@ function testMenuNodeFormWidget() { $edit = array( 'menu[enabled]' => FALSE, ); - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); // Assert that there is no link for the node. $this->drupalGet('test-page'); $this->assertNoLink($node_title); @@ -140,7 +141,7 @@ function testMenuNodeFormWidget() { $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertText('Provide a menu link', 'Link in not allowed menu not shown in node edit form'); // Assert that the link is still in the Administration menu after save. - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); $link = MenuLinkContent::load($item->id()); $this->assertTrue($link, 'Link in not allowed menu still exists after saving node');