You are here

public function MassPasswordResetConfirm::buildForm in Mass Password Change 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfirmFormBase::buildForm

File

src/Form/MassPasswordResetConfirm.php, line 85

Class

MassPasswordResetConfirm
Provides a confirmation form for mass password reset action.

Namespace

Drupal\mass_password_change\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Retrieve the accounts to be canceled from the temp store.

  /* @var \Drupal\user\Entity\User[] $accounts */
  $accounts = $this->tempStoreFactory
    ->get('mass_password_change')
    ->get('password_reset');
  if (!$accounts) {
    return $this
      ->redirect('entity.user.collection');
  }
  $list = [];
  foreach ($accounts as $account) {
    $uid = $account
      ->id();
    $list[$uid] = $account
      ->getAccountName();
    $form['accounts'][$uid] = [
      '#type' => 'hidden',
      '#value' => $uid,
    ];
  }
  $form['accounts']['#tree'] = TRUE;
  $form['account']['names'] = [
    '#theme' => 'item_list',
    '#items' => $list,
  ];
  $form = parent::buildForm($form, $form_state);
  return $form;
}