You are here

protected function ProfileForm::actions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/ProfileForm.php \Drupal\user\ProfileForm::actions()

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.

Overrides EntityForm::actions

File

core/modules/user/src/ProfileForm.php, line 30
Contains \Drupal\user\ProfileForm.

Class

ProfileForm
Form controller for the profile forms.

Namespace

Drupal\user

Code

protected function actions(array $form, FormStateInterface $form_state) {
  $element = parent::actions($form, $form_state);

  // The user account being edited.
  $account = $this->entity;

  // The user doing the editing.
  $user = $this
    ->currentUser();
  $element['delete']['#type'] = 'submit';
  $element['delete']['#value'] = $this
    ->t('Cancel account');
  $element['delete']['#submit'] = array(
    '::editCancelSubmit',
  );
  $element['delete']['#access'] = $account
    ->id() > 1 && ($account
    ->id() == $user
    ->id() && $user
    ->hasPermission('cancel account') || $user
    ->hasPermission('administer users'));
  return $element;
}