You are here

function email_registration_form_user_pass_alter in Email Registration 8

Same name and namespace in other branches
  1. 6 email_registration.module \email_registration_form_user_pass_alter()
  2. 7 email_registration.module \email_registration_form_user_pass_alter()

Implements hook_form_FORM_ID_alter().

File

./email_registration.module, line 145
Allows users to register with an email address as their username.

Code

function email_registration_form_user_pass_alter(&$form, FormStateInterface $form_state) {
  $form['name']['#title'] = t('Email');

  // Only convert textfields to email fields. This field is a hidden value when
  // you are already logged in.
  if ($form['name']['#type'] === 'textfield') {

    // Allow client side validation of input format.
    $form['name']['#type'] = 'email';
    $form['name']['#maxlength'] = Email::EMAIL_MAX_LENGTH;
  }
}