function user_form_process_password_confirm

Same name in other branches
  1. 7.x modules/user/user.module \user_form_process_password_confirm()
  2. 8.9.x core/modules/user/user.module \user_form_process_password_confirm()
  3. 10 core/modules/user/user.module \user_form_process_password_confirm()
  4. 11.x core/modules/user/user.module \user_form_process_password_confirm()

Form element process handler for client-side password validation.

This #process handler is automatically invoked for 'password_confirm' form elements to add the JavaScript and string translations for dynamic password validation.

1 string reference to 'user_form_process_password_confirm'
user_element_info_alter in core/modules/user/user.module
Implements hook_element_info_alter().

File

core/modules/user/user.module, line 1095

Code

function user_form_process_password_confirm($element) {
    $password_settings = [
        'confirmTitle' => t('Passwords match:'),
        'confirmSuccess' => t('yes'),
        'confirmFailure' => t('no'),
        'showStrengthIndicator' => FALSE,
    ];
    if (\Drupal::config('user.settings')->get('password_strength')) {
        $password_settings['showStrengthIndicator'] = TRUE;
        $password_settings += [
            'strengthTitle' => t('Password strength:'),
            'hasWeaknesses' => t('Recommendations to make your password stronger:'),
            'tooShort' => t('Make it at least 12 characters'),
            'addLowerCase' => t('Add lowercase letters'),
            'addUpperCase' => t('Add uppercase letters'),
            'addNumbers' => t('Add numbers'),
            'addPunctuation' => t('Add punctuation'),
            'sameAsUsername' => t('Make it different from your username'),
            'weak' => t('Weak'),
            'fair' => t('Fair'),
            'good' => t('Good'),
            'strong' => t('Strong'),
            'username' => \Drupal::currentUser()->getAccountName(),
        ];
    }
    $element['#attached']['library'][] = 'user/drupal.user';
    $element['#attached']['drupalSettings']['password'] = $password_settings;
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.