W3cubDocs

/Drupal 8

public static function 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!PasswordConfirm.php/function/PasswordConfirm::processPasswordConfirm/8.1.x