protected function EntityFormController::actionsElement

Returns the action form element for the current entity form.

2 calls to EntityFormController::actionsElement()
1 method overrides EntityFormController::actionsElement()

File

drupal/core/lib/Drupal/Core/Entity/EntityFormController.php, line 89
Definition of Drupal\Core\Entity\EntityFormController.

Class

EntityFormController
Base class for entity form controllers.

Namespace

Drupal\Core\Entity

Code

protected function actionsElement(array $form, array &$form_state) {
  $element = $this
    ->actions($form, $form_state);

  // We cannot delete an entity that has not been created yet.
  if ($this
    ->getEntity($form_state)
    ->isNew()) {
    unset($element['delete']);
  }
  elseif (isset($element['delete'])) {

    // Move the delete action as last one, unless weights are explicitly
    // provided.
    $delete = $element['delete'];
    unset($element['delete']);
    $element['delete'] = $delete;
    $element['delete']['#button_type'] = 'danger';
  }
  if (isset($element['submit'])) {

    // Give the primary submit button a #button_type of primary.
    $element['submit']['#button_type'] = 'primary';
  }
  $count = 0;
  foreach (element_children($element) as $action) {
    $element[$action] += array(
      '#type' => 'submit',
      '#weight' => ++$count * 5,
    );
  }
  if (!empty($element)) {
    $element['#type'] = 'actions';
  }
  return $element;
}