function claro_form_views_ui_add_handler_form_alter

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

Implements hook_form_FORM_ID_alter() for Views UI add handler form.

File

core/themes/claro/claro.theme, line 1615

Code

function claro_form_views_ui_add_handler_form_alter(array &$form, FormStateInterface $form_state) {
    // Remove container-inline class to allow more control over styling.
    if (isset($form['selected']['#attributes']['class'])) {
        $form['selected']['#attributes']['class'] = array_diff($form['selected']['#attributes']['class'], [
            'container-inline',
        ]);
    }
    // Move all form elements in controls to its parent, this places them all in
    // the same div, which makes it possible to position them with flex styling
    // instead of floats.
    if (isset($form['override']['controls'])) {
        foreach (Element::children($form['override']['controls']) as $key) {
            $form['override']["controls_{$key}"] = $form['override']['controls'][$key];
            // The wrapper array for controls is removed after this loop completes.
            // The wrapper ensured that its child elements were hidden in browsers
            // without JavaScript. To replicate this functionality, the `.js-show`
            // class is added to each item previously contained in the wrapper.
            if (isset($form['override']['controls']['#id']) && $form['override']['controls']['#id'] === 'views-filterable-options-controls') {
                $form['override']["controls_{$key}"]['#wrapper_attributes']['class'][] = 'js-show';
            }
        }
        unset($form['override']['controls']);
    }
}

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