function olivero_preprocess_input

Same name in other branches
  1. 10 core/themes/olivero/olivero.theme \olivero_preprocess_input()
  2. 11.x core/themes/olivero/olivero.theme \olivero_preprocess_input()

Implements hook_preprocess_HOOK().

File

core/themes/olivero/olivero.theme, line 273

Code

function olivero_preprocess_input(&$variables) {
    if (!empty($variables['element']['#title_display']) && $variables['element']['#title_display'] === 'attribute' && !empty((string) $variables['element']['#title'])) {
        $variables['attributes']['title'] = (string) $variables['element']['#title'];
    }
    $type_api = $variables['element']['#type'];
    $type_html = $variables['attributes']['type'];
    $text_types_html = [
        'text',
        'email',
        'tel',
        'number',
        'search',
        'password',
        'date',
        'time',
        'file',
        'color',
        'datetime-local',
        'url',
        'month',
        'week',
    ];
    if (in_array($type_html, $text_types_html, TRUE)) {
        $variables['attributes']['class'][] = 'form-element';
        $variables['attributes']['class'][] = Html::getClass('form-element--type-' . $type_html);
        $variables['attributes']['class'][] = Html::getClass('form-element--api-' . $type_api);
        // This logic is functioning as expected, but there is nothing in the theme that renders the result.
        // As a result it can't currently be covered by a functional test.
        if (!empty($variables['element']['#autocomplete_route_name'])) {
            $variables['autocomplete_message'] = t('Loading…');
        }
    }
    if (in_array($type_html, [
        'checkbox',
        'radio',
    ], TRUE)) {
        $variables['attributes']['class'][] = 'form-boolean';
        $variables['attributes']['class'][] = Html::getClass('form-boolean--type-' . $type_html);
    }
}

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