public function PasswordReset::buildForm in Password Policy 8.3
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 FormInterface::buildForm
File
- src/
Form/ PasswordReset.php, line 64
Class
- PasswordReset
- Provides a form to reset user passwords by role.
Namespace
Drupal\password_policy\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$options = [];
foreach ($this->roleStorage
->loadMultiple() as $role) {
$options[$role
->id()] = $role
->label();
}
unset($options[AccountInterface::ANONYMOUS_ROLE]);
$form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Roles'),
'#description' => $this
->t('Force password reset of selected roles.'),
'#options' => $options,
];
$form['exclude_myself'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Exclude Myself'),
'#description' => $this
->t('Exclude your account if you are included in the roles.'),
'#default_value' => '1',
];
$form['save'] = [
'#type' => 'submit',
'#value' => $this
->t('Save'),
];
return $form;
}