function PasswordConfirm::processPasswordConfirm
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Element/PasswordConfirm.php \Drupal\Core\Render\Element\PasswordConfirm::processPasswordConfirm()
- 8.9.x core/lib/Drupal/Core/Render/Element/PasswordConfirm.php \Drupal\Core\Render\Element\PasswordConfirm::processPasswordConfirm()
- 10 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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.