You are here

public static function PasswordConfirm::processPasswordConfirm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 72
Contains \Drupal\Core\Render\Element\PasswordConfirm.

Class

PasswordConfirm
Provides a form element for double-input of passwords.

Namespace

Drupal\Core\Render\Element

Code

public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) {
  $element['pass1'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
    '#required' => $element['#required'],
    '#attributes' => array(
      'class' => array(
        'password-field',
        'js-password-field',
      ),
    ),
    '#error_no_message' => TRUE,
  );
  $element['pass2'] = array(
    '#type' => 'password',
    '#title' => t('Confirm password'),
    '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
    '#required' => $element['#required'],
    '#attributes' => array(
      'class' => array(
        'password-confirm',
        'js-password-confirm',
      ),
    ),
    '#error_no_message' => TRUE,
  );
  $element['#element_validate'] = array(
    array(
      get_called_class(),
      'validatePasswordConfirm',
    ),
  );
  $element['#tree'] = TRUE;
  if (isset($element['#size'])) {
    $element['pass1']['#size'] = $element['pass2']['#size'] = $element['#size'];
  }
  return $element;
}