You are here

function claro_form_views_ui_add_handler_form_alter in Drupal 9

Same name and namespace in other branches
  1. 10 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 1593
Functions to support theming in the Claro theme.

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']);
  }
}