function UserLoginForm::validateName

Same name and namespace in other branches
  1. 9 core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::validateName()
  2. 8.9.x core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::validateName()

Sets an error if supplied username has been blocked.

Deprecated

in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement.

See also

https://www.drupal.org/node/3410706

File

core/modules/user/src/Form/UserLoginForm.php, line 173

Class

UserLoginForm
Provides a user login form.

Namespace

Drupal\user\Form

Code

public function validateName(array &$form, FormStateInterface $form_state) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3410706', E_USER_DEPRECATED);
    if (!$form_state->isValueEmpty('name') && user_is_blocked($form_state->getValue('name'))) {
        // Blocked in user administration.
        $form_state->setErrorByName('name', $this->t('The username %name has not been activated or is blocked.', [
            '%name' => $form_state->getValue('name'),
        ]));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.