function language_element_info_alter

Same name in other branches
  1. 8.9.x core/modules/language/language.module \language_element_info_alter()
  2. 10 core/modules/language/language.module \language_element_info_alter()

Implements hook_element_info_alter().

See also

\Drupal\Core\Render\Element\LanguageSelect

\Drupal\Core\Render\Element\Select

File

core/modules/language/language.module, line 121

Code

function language_element_info_alter(&$type) {
    // Alter the language_select element so that it will be rendered like a select
    // field.
    if (isset($type['language_select'])) {
        if (!isset($type['language_select']['#process'])) {
            $type['language_select']['#process'] = [];
        }
        if (!isset($type['language_select']['#theme_wrappers'])) {
            $type['language_select']['#theme_wrappers'] = [];
        }
        $type['language_select']['#process'] = array_merge($type['language_select']['#process'], [
            'language_process_language_select',
            [
                'Drupal\\Core\\Render\\Element\\Select',
                'processSelect',
            ],
            [
                'Drupal\\Core\\Render\\Element\\RenderElement',
                'processAjaxForm',
            ],
        ]);
        $type['language_select']['#theme'] = 'select';
        $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], [
            'form_element',
        ]);
        $type['language_select']['#languages'] = LanguageInterface::STATE_CONFIGURABLE;
        $type['language_select']['#multiple'] = FALSE;
    }
}

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