ProfileForm::actions

protected ProfileForm::actions(array $form, FormStateInterface $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.

Overrides EntityForm::actions

File

core/modules/user/src/ProfileForm.php, line 25

Class

ProfileForm
Form handler 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;
}
doc_Drupal
2016-10-29 09:35:04
Comments
Leave a Comment

Please login to continue.