function LanguageHooks::elementInfoAlter

Implements hook_element_info_alter().

See also

\Drupal\Core\Render\Element\LanguageSelect

\Drupal\Core\Render\Element\Select

File

core/modules/language/src/Hook/LanguageHooks.php, line 160

Class

LanguageHooks
Hook implementations for language.

Namespace

Drupal\language\Hook

Code

public function elementInfoAlter(&$type) : void {
    // 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\\RenderElementBase',
                '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.