Skip to content

Instantly share code, notes, and snippets.

@clrockwell
Created September 9, 2017 16:15
Show Gist options
  • Save clrockwell/ca32d4c82b721a1078acd95a6fde01df to your computer and use it in GitHub Desktop.
Save clrockwell/ca32d4c82b721a1078acd95a6fde01df to your computer and use it in GitHub Desktop.
Drupal 8: altering a @FormElement - update password_confirm element to require 6 characters
<?php
/**
* Implements hook_element_info_alter().
*/
function scholarrx_user_registration_element_info_alter(array &$info) {
$info['password_confirm']['#process'][] = 'scholarrx_process_password_confirm';
}
function scholarrx_process_password_confirm(&$element, FormStateInterface $form_state, &$complete_form) {
$element['pass1']['#attributes']['minlength'] = 6;
return $element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment