function UserLoginForm::validateName
Sets an error if supplied username has been blocked.
File
-
core/
modules/ user/ src/ Form/ UserLoginForm.php, line 177
Class
- UserLoginForm
- Provides a user login form.
Namespace
Drupal\user\FormCode
public function validateName(array &$form, FormStateInterface $form_state) {
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.