Ajax callback not working with 'language_select' in drupal 8 forms I'm trying to implement an ajax callback whenever language gets changed. Following code I have used:

public function buildForm(array $form, FormStateInterface $form_state) {
$language = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();
$langcode = $from_database-&gt;lid;
$form['langcode'] = array(
           '#title' =&gt; $this-&gt;t('Language'),
           '#type' =&gt; 'language_select',
           '#default_value' =&gt; !empty($langcode) ? $langcode : $language,
           '#languages' =&gt; Language::STATE_ALL,
           '#ajax' =&gt; array(
        'callback' =&gt; ::ajax_example_autocheckboxes_callback',
        'wrapper' =&gt; 'checkboxes-div',

       ) ,
       );

$form['checkboxes_fieldset'] = array(
  '#title' =&gt; t("Generated Checkboxes"),
  // The prefix/suffix provide the div that we're replacing, named by
  // #ajax['wrapper'] above.
  '#prefix' =&gt; '&lt;div id="checkboxes-div"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#type' =&gt; 'fieldset',
  '#description' =&gt; t('This is where we get automatically generated    checkboxes'),
 );
}

function ajax_example_autocheckboxes_callback($form, $form_state) {
  return $form['checkboxes_fieldset'];
}


But ajax callback is not working. Suggest a way to implement ajax on language select.
Try adding a container. It works for me:

public function buildForm(array $form, FormStateInterface $form_state){
    $current_user = \Drupal::currentUser();
    $user_preferred_langcode = $current_user-&gt;getPreferredLangcode();

    // The status messages that will contain any form errors.
    $form['status_messages'] = [
     '#type' =&gt; 'status_messages',
     '#weight' =&gt; -10,
    ];

    $form['title'] = [
      '#type' =&gt; 'html_tag',
      '#tag' =&gt; 'h2',
      '#value' =&gt; t('Change Language'),
    ];

    $form['preferred_langcode'] = [
      '#type' =&gt; 'language_select',
      '#languages' =&gt; LanguageInterface::STATE_CONFIGURABLE,
      '#default_value' =&gt; $user_preferred_langcode,
      '#ajax' =&gt; [
        'callback' =&gt; [$this, 'languageCallback'],
        'event' =&gt; 'change',
        'wrapper' =&gt; 'language-wrapper',
      ],
    ];

    $form['language_wrapper'] = [
      '#type' =&gt; 'container',
      '#attributes' =&gt; ['id' =&gt; 'language-wrapper'],
    ];

    $preferred_langcode = $form_state-&gt;getValue('preferred_langcode');

   if(empty($preferred_langcode) || $user_preferred_langcode == 
$preferred_langcode) {
      $form['language_wrapper']['default_language'] = [
        '#type' =&gt; 'html_tag',
        '#tag' =&gt; 'p',
        '#value' =&gt; $this-&gt;t('Your Current Language'),
      ];
    }

    $form_state-&gt;setCached(FALSE);

    return $form;
  }

  public function languageCallback(array $form, FormStateInterface $form_state) {
    return $form['language_wrapper'];
  }