diff --git a/core/includes/common.inc b/core/includes/common.inc index 37e9b87..4487adc 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3098,25 +3098,25 @@ function drupal_pre_render_link($element) { // By default, link options to pass to l() are normally set in #options. $element += array('#options' => array()); + // However, within the scope of renderable elements, #attributes is a valid + // way to specify attributes, too. Take them into account, but do not override + // attributes from #options. + if (isset($element['#attributes'])) { + $element['#options'] += array('attributes' => array()); + $element['#options']['attributes'] += $element['#attributes']; + } + // Support for button links. // Setting #button_type on #type 'link' to an empty string adds the .button // class only, unless a more specific #button_type has been specified. // @see form_pre_render_button() if (isset($element['#button_type'])) { - $element['#attributes']['class'][] = 'button'; + $element['#options']['attributes']['class'][] = 'button'; if (!empty($element['#button_type'])) { - $element['#attributes']['class'][] = 'button--' . $element['#button_type']; + $element['#options']['attributes']['class'][] = 'button--' . $element['#button_type']; } } - // Within the scope of renderable elements, #attributes is a valid - // way to specify attributes, too. Take them into account, but do not override - // attributes from #options. - if (isset($element['#attributes'])) { - $element['#options'] += array('attributes' => array()); - $element['#options']['attributes'] += $element['#attributes']; - } - // This #pre_render callback can be invoked from inside or outside of a Form // API context, and depending on that, a HTML ID may be already set in // different locations. #options should have precedence over Form API's #id. diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index b177a2a..e8d0835 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -230,9 +230,7 @@ protected function actions(array $form, array &$form_state) { $actions['delete'] = array( '#type' => 'link', '#title' => $this->t('Delete'), - '#attributes' => array( - 'class' => array('button', 'button--danger'), - ), + '#button_type' => 'danger', ); $actions['delete'] += $route_info->toRenderArray(); }