public UserLoginForm::buildForm(array $form, FormStateInterface $form_state)
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- core/modules/user/src/Form/UserLoginForm.php, line 87
Class
- UserLoginForm
- Provides a user login form.
Namespace
Drupal\user\Form
Code
public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('system.site'); // Display login form: $form['name'] = array( '#type' => 'textfield', '#title' => $this->t('Username'), '#size' => 60, '#maxlength' => USERNAME_MAX_LENGTH, '#description' => $this->t('Enter your @s username.', array('@s' => $config->get('name'))), '#required' => TRUE, '#attributes' => array( 'autocorrect' => 'none', 'autocapitalize' => 'none', 'spellcheck' => 'false', 'autofocus' => 'autofocus', ), ); $form['pass'] = array( '#type' => 'password', '#title' => $this->t('Password'), '#size' => 60, '#description' => $this->t('Enter the password that accompanies your username.'), '#required' => TRUE, ); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Log in')); $form['#validate'][] = '::validateName'; $form['#validate'][] = '::validateAuthentication'; $form['#validate'][] = '::validateFinal'; $this->renderer->addCacheableDependency($form, $config); return $form; }
Please login to continue.