1 user.module user_form_process_password($element)

Form element process handler for client-side password hide/show and strength.

Parameters

$element:

File

core/modules/user/user.module, line 2699
Enables the user registration and login system.

Code

function user_form_process_password($element) {
  global $user;

  if ($element['#password_strength']) {
    $strength_settings = array(
      'strengthTitle' => t('Password strength: '),
      'weak' => t('poor'),
      'fair' => t('fair'),
      'good' => t('good'),
      'strong' => t('excellent'),
      'username' => (isset($user->name) ? $user->name : ''),
    );

    $element['#attributes']['data-password-strength'] = backdrop_json_encode($strength_settings, FALSE);
  }

  if ($element['#password_toggle']) {
    $toggle_settings = array(
      'toggleShowTitle' => t('Show password'),
      'toggleHideTitle' => t('Hide password'),
      'toggleDefault' => $element['#password_shown'] ? 'show' : 'hide',
    );

    $element['#attributes']['data-password-toggle'] = backdrop_json_encode($toggle_settings, FALSE);
  }

  if ($element['#password_strength'] || $element['#password_toggle']) {
    $element['#attached']['js'][] = backdrop_get_path('module', 'user') . '/js/user.js';
  }
  return $element;
}