PasswordConfirm::processPasswordConfirm

public static PasswordConfirm::processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form)

Expand a password_confirm field into two text boxes.

File

core/lib/Drupal/Core/Render/Element/PasswordConfirm.php, line 67

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;
}
doc_Drupal
2016-10-29 09:33:14
Comments
Leave a Comment

Please login to continue.