Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Question

How to add “Remember me” checkbox to login form in Drupal 8?

Solution

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    if ($form_id == 'user_login_form') {
        $form['remember_me'] = [
            '#type'          => 'checkbox',
            '#title'         => t('Remember me'),
            '#default_value' => FALSE,
        ];
    }
}

Screenshot

remember me login form

 

Tags :

Riadh Rahmi

Senior Web Developer (Drupal & Laravel)

I am a senior web developer, I have experience in planning and developing large scale dynamic web applications especially in Drupal and Laravel.

Web Posts

Search

Page Facebook