diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 440aa50..e4a6456 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -217,7 +217,6 @@ protected function actionsElement(array $form, array &$form_state) { $count = 0; foreach (element_children($element) as $action) { $element[$action] += array( - '#type' => 'submit', '#weight' => ++$count * 5, ); } @@ -231,30 +230,45 @@ protected function actionsElement(array $form, array &$form_state) { /** * Returns an array of supported actions for the current entity form. + * + * @todo Consider introducing a 'preview' action here, since it is used by + * many entity types. */ protected function actions(array $form, array &$form_state) { - return array( - // @todo Rename the action key from submit to save. - 'submit' => array( - '#value' => $this->t('Save'), - '#validate' => array( - array($this, 'validate'), - ), - '#submit' => array( - array($this, 'submit'), - array($this, 'save'), - ), + // @todo Rename the action key from submit to save. + $actions['submit'] = array( + '#type' => 'submit', + '#value' => $this->t('Save'), + '#validate' => array( + array($this, 'validate'), ), - 'delete' => array( - '#value' => $this->t('Delete'), - // No need to validate the form when deleting the entity. - '#submit' => array( - array($this, 'delete'), - ), + '#submit' => array( + array($this, 'submit'), + array($this, 'save'), ), - // @todo Consider introducing a 'preview' action here, since it is used by - // many entity types. ); + + if ($this->entity->hasLinkTemplate('delete-form') && !$this->entity->isNew()) { + $route_info = $this->entity->urlInfo('delete-form'); + $route_info += array( + 'route_parameters' => array(), + ); + if ($this->getRequest()->query->has('destination')) { + $route_info['options']['query']['destination'] = $this->getRequest()->query->get('destination'); + } + $actions['delete'] = array( + '#type' => 'link', + '#title' => $this->t('Delete'), + '#attributes' => array( + 'class' => array('button', 'button--danger'), + ), + '#options' => $route_info['options'], + '#route_name' => $route_info['route_name'], + '#route_parameters' => $route_info['route_parameters'], + ); + } + + return $actions; } /** @@ -302,26 +316,6 @@ public function save(array $form, array &$form_state) { } /** - * Form submission handler for the 'delete' action. - * - * @param array $form - * An associative array containing the structure of the form. - * @param array $form_state - * A reference to a keyed array containing the current state of the form. - */ - public function delete(array $form, array &$form_state) { - if ($this->entity->hasLinkTemplate('delete-form')) { - $form_state['redirect_route'] = $this->entity->urlInfo('delete-form'); - - $query = $this->getRequest()->query; - if ($query->has('destination')) { - $form_state['redirect_route']['options']['query']['destination'] = $query->get('destination'); - $query->remove('destination'); - } - } - } - - /** * {@inheritdoc} */ public function getFormLangcode(array &$form_state) { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php index 5bd711c..4f8903a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php @@ -70,7 +70,7 @@ public function testPageEdit() { // Test deleting the block. $this->drupalGet("block/" . $revised_block->id()); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->clickLink(t('Delete')); $this->assertText(format_string('Are you sure you want to delete !label?', array('!label' => $revised_block->label()))); } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index e7b99e1..fc586d8 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -137,7 +137,7 @@ function testBlock() { // Test deleting the block from the edit form. $this->drupalGet('admin/structure/block/manage/' . $block['id']); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->clickLink(t('Delete')); $this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block['settings[label]']))); $this->drupalPostForm(NULL, array(), t('Delete')); $this->assertRaw(t('The block %name has been removed.', array('%name' => $block['settings[label]']))); @@ -145,7 +145,7 @@ function testBlock() { // Test deleting a block via "Configure block" link. $block = $this->drupalPlaceBlock('system_powered_by_block'); $this->drupalGet('admin/structure/block/manage/' . $block->id(), array('query' => array('destination' => 'admin'))); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->clickLink(t('Delete')); $this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block->label()))); $this->drupalPostForm(NULL, array(), t('Delete')); $this->assertRaw(t('The block %name has been removed.', array('%name' => $block->label()))); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index 19ebaff..5a4e0b8 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -220,7 +220,7 @@ function testCRUDUI() { // Delete the configuration entity. $this->drupalGet("admin/structure/config_test/manage/$id"); - $this->drupalPostForm(NULL, array(), 'Delete'); + $this->clickLink(t('Delete')); $this->assertUrl("admin/structure/config_test/manage/$id/delete"); $this->drupalPostForm(NULL, array(), 'Delete'); $this->assertUrl('admin/structure/config_test'); diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php index 29a46b5..1a4ca2a 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php @@ -59,7 +59,7 @@ public function testEntityViewModeUI() { $this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']); // Test deleting the view mode. - $this->drupalPostForm(NULL, NULL, t('Delete')); + $this->clickLink(t('Delete')); $this->assertRaw(t('Are you sure you want to delete the %label view mode?', array('%label' => $edit['label']))); $this->drupalPostForm(NULL, NULL, t('Delete')); $this->assertRaw(t('Deleted the %label view mode.', array('%label' => $edit['label']))); @@ -95,7 +95,7 @@ public function testEntityFormModeUI() { $this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']); // Test deleting the form mode. - $this->drupalPostForm(NULL, NULL, t('Delete')); + $this->clickLink(t('Delete')); $this->assertRaw(t('Are you sure you want to delete the %label form mode?', array('%label' => $edit['label']))); $this->drupalPostForm(NULL, NULL, t('Delete')); $this->assertRaw(t('Deleted the %label form mode.', array('%label' => $edit['label']))); diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php index ae16f90..ae730ce 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php @@ -101,14 +101,23 @@ public function save(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function delete(array $form, array &$form_state) { - $form_state['redirect_route'] = $this->entity->urlInfo('forum-delete-form'); - - $query = $this->getRequest()->query; - if ($query->has('destination')) { - $form_state['redirect_route']['options']['query']['destination'] = $query->get('destination'); - $query->remove('destination'); + protected function actions(array $form, array &$form_state) { + $actions = parent::actions($form, $form_state); + + if ($this->entity->hasLinkTemplate('forum-delete-form') && !$this->entity->isNew()) { + $route_info = $this->entity->urlInfo('forum-delete-form'); + $route_info += array( + 'route_parameters' => array(), + ); + $actions['delete']['#options'] = $route_info['options']; + $actions['delete']['#route_name'] = $route_info['route_name']; + $actions['delete']['#route_parameters'] = $route_info['route_parameters']; + } + else { + unset($actions['delete']); } + + return $actions; } /** diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index a706f74..2e34305 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -307,7 +307,7 @@ private function doAdminTests($user) { // Test tags vocabulary form is not affected. $this->drupalGet('admin/structure/taxonomy/manage/tags'); $this->assertFieldByName('op', t('Save'), 'Save button found.'); - $this->assertFieldByName('op', t('Delete'), 'Delete button found.'); + $this->assertLink(t('Delete')); // Test tags vocabulary term form is not affected. $this->drupalGet('admin/structure/taxonomy/manage/tags/add'); $this->assertField('parent[]', 'Parent field found.'); @@ -408,7 +408,8 @@ function createForum($type, $parent = 0) { */ function deleteForum($tid) { // Delete the forum. - $this->drupalPostForm('admin/structure/forum/edit/forum/' . $tid, array(), t('Delete')); + $this->drupalGet('admin/structure/forum/edit/forum/' . $tid); + $this->clickLink(t('Delete')); $this->assertText('Are you sure you want to delete the forum'); $this->assertNoText('Add forum'); $this->assertNoText('Add forum container'); diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index 569f502..f2afc4e 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -293,6 +293,7 @@ protected function actions(array $form, array &$form_state) { array($this, 'submit'), array($this, 'preview'), ), + '#type' => 'submit', ); $element['delete']['#access'] = $node->access('delete'); diff --git a/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php b/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php index 1e4b106..6691eda 100644 --- a/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php +++ b/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php @@ -91,25 +91,6 @@ public function form(array $form, array &$form_state) { } /** - * Overrides Drupal\Core\Entity\EntityFormController::actions(). - */ - protected function actions(array $form, array &$form_state) { - // Only includes a Save action for the entity, no direct Delete button. - return array( - 'submit' => array( - '#value' => $this->t('Save'), - '#validate' => array( - array($this, 'validate'), - ), - '#submit' => array( - array($this, 'submit'), - array($this, 'save'), - ), - ), - ); - } - - /** * Overrides Drupal\Core\Entity\EntityFormController::validate(). */ public function validate(array $form, array &$form_state) { diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index 749ee44..3e5a400 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -108,6 +108,22 @@ public function save(array $form, array &$form_state) { } /** + * {@inheritdoc} + */ + protected function actions(array $form, array &$form_state) { + $actions = parent::actions($form, $form_state); + $actions['delete'] = array( + '#value' => $this->t('Delete'), + '#submit' => array( + array($this, 'delete'), + ), + '#type' => 'submit', + ); + + return $actions; + } + + /** * Overrides Drupal\Core\Entity\EntityFormController::delete(). */ public function delete(array $form, array &$form_state) { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 5a53567..772b772 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -201,11 +201,13 @@ function testNodeTermCreationAndDeletion() { } // Delete term 1 from the term edit page. - $this->drupalPostForm('taxonomy/term/' . $term_objects['term1']->id() . '/edit', array(), t('Delete')); + $this->drupalGet('taxonomy/term/' . $term_objects['term1']->id() . '/edit'); + $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, NULL, t('Delete')); // Delete term 2 from the term delete page. - $this->drupalPostForm('taxonomy/term/' . $term_objects['term2']->id() . '/delete', array(), t('Delete')); + $this->drupalGet('taxonomy/term/' . $term_objects['term2']->id() . '/delete'); + $this->drupalPostForm(NULL, array(), t('Delete')); $term_names = array($term_objects['term3']->label(), $term_objects['term4']->label()); // Get the node. @@ -359,7 +361,8 @@ function testTermInterface() { $this->drupalGet('taxonomy/term/' . $term->id() . '/feed'); // Delete the term. - $this->drupalPostForm('taxonomy/term/' . $term->id() . '/edit', array(), t('Delete')); + $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); + $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, NULL, t('Delete')); // Assert that the term no longer exists. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php index ec22ffd..7506c59 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php @@ -140,8 +140,8 @@ function testTaxonomyAdminDeletingVocabulary() { $this->assertTrue($vocabulary, 'Vocabulary found.'); // Delete the vocabulary. - $edit = array(); - $this->drupalPostForm('admin/structure/taxonomy/manage/' . $vocabulary->id(), $edit, t('Delete')); + $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id()); + $this->clickLink(t('Delete')); $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->name)), '[confirm deletion] Asks for confirmation.'); $this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), '[confirm deletion] Inform that all terms will be deleted.'); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php index 2658b1a..531c441 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php @@ -68,7 +68,8 @@ function testRoleAdministration() { $this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.'); // Test deleting a role. - $this->drupalPostForm("admin/people/roles/manage/{$role->id()}", array(), t('Delete')); + $this->drupalGet("admin/people/roles/manage/{$role->id()}"); + $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, array(), t('Delete')); $this->assertRaw(t('Role %label has been deleted.', array('%label' => $role_name))); $this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php index 7477184..c204e85 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php @@ -155,6 +155,7 @@ protected function actions(array $form, array &$form_state) { array($this, 'cancel'), ), '#limit_validation_errors' => array(), + '#type' => 'submit', ); return $actions; } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php index 6d9e85b..281920e 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php @@ -58,6 +58,7 @@ protected function actions(array $form, array &$form_state) { '#submit' => array( array($this, 'submit'), ), + '#type' => 'submit', ); return $actions; } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php index 9d3b6bd..c70c090 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php @@ -224,6 +224,7 @@ protected function actions(array $form, array &$form_state) { '#submit' => array( array($this, 'cancel'), ), + '#type' => 'submit', ); return $actions; } diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php old mode 100644 new mode 100755