diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 440aa50..143d438 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,40 @@ 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( + '#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. + '#type' => 'submit', ); + + if ($this->entity->hasLinkTemplate('delete-form') && !$this->entity->isNew()) { + $route_info = $this->entity->urlInfo('delete-form'); + $route_info += array( + 'route_parameters' => array(), + ); + $actions['delete'] = array( + '#type' => 'link', + '#title' => $this->t('Delete'), + '#class' => array('button--danger'), + '#options' => $route_info['options'], + '#route_name' => $route_info['route_name'], + '#route_parameters' => $route_info['route_parameters'], + ); + } + + return $actions; } /** @@ -302,26 +311,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/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index e7b99e1..b3489e2 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]']))); diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php old mode 100644 new mode 100755