public static function PasswordConfirm::processPasswordConfirm in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Render/Element/PasswordConfirm.php \Drupal\Core\Render\Element\PasswordConfirm::processPasswordConfirm()
- 9 core/lib/Drupal/Core/Render/Element/PasswordConfirm.php \Drupal\Core\Render\Element\PasswordConfirm::processPasswordConfirm()
Expand a password_confirm field into two text boxes.
File
- core/
lib/ Drupal/ Core/ Render/ Element/ PasswordConfirm.php, line 70
Class
- PasswordConfirm
- Provides a form element for double-input of passwords.
Namespace
Drupal\Core\Render\ElementCode
public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) {
$element['pass1'] = [
'#type' => 'password',
'#title' => t('Password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
'#required' => $element['#required'],
'#attributes' => [
'class' => [
'password-field',
'js-password-field',
],
'autocomplete' => [
'new-password',
],
],
'#error_no_message' => TRUE,
];
$element['pass2'] = [
'#type' => 'password',
'#title' => t('Confirm password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
'#required' => $element['#required'],
'#attributes' => [
'class' => [
'password-confirm',
'js-password-confirm',
],
'autocomplete' => [
'new-password',
],
],
'#error_no_message' => TRUE,
];
$element['#element_validate'] = [
[
static::class,
'validatePasswordConfirm',
],
];
$element['#tree'] = TRUE;
if (isset($element['#size'])) {
$element['pass1']['#size'] = $element['pass2']['#size'] = $element['#size'];
}
return $element;
}