Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Form Alter, check for form user_form
- function base_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
- if ($form_id == 'user_form') {
- $form['#validate'][] = '_user_form_validation';
- }
- }
- //Validation example
- function _user_form_validation(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
- if ($form_state->hasValue('pass')) {
- $pass = $form_state->getValue('pass');
- if (strlen($pass) < 6 ) {
- $form_state->setErrorByName('pass', t('Password length must be at least 6 characters.'));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement