You are here

views_ef_fieldset.module in Views Exposed Form Fieldset 8

Same filename and directory in other branches
  1. 7.2 views_ef_fieldset.module
  2. 7 views_ef_fieldset.module

File

views_ef_fieldset.module
View source
<?php

/**
 * @file
 * Main module file.
 */
declare (strict_types=1);
use Drupal\Core\Form\FormStateInterface;
use Drupal\views_ef_fieldset\ViewsEFFieldsetData;

/**
 * Implements hook_form_FORM_ID_alter().
 */
function views_ef_fieldset_form_views_exposed_form_alter(array &$form, FormStateInterface &$form_state, $form_id) {
  if ($display = $form_state
    ->get('display')) {
    if (!empty($display['display_options']['display_extenders']['views_ef_fieldset']['views_ef_fieldset'])) {
      $options = $display['display_options']['display_extenders']['views_ef_fieldset']['views_ef_fieldset'];
      if (!empty($options['enabled'])) {
        $form['filters']['#attached']['library'][] = 'views_ef_fieldset/views_ef_fieldset.styling';
        if (isset($options['options']['sort'])) {
          $viewsEFFieldsetData = new ViewsEFFieldsetData($options['options']['sort'], $form);
          $form['filters']['children'] = $viewsEFFieldsetData
            ->treetofapi();
          $form['#info']['views_ef_fieldset']['value'] = 'filters';
        }
      }
    }
  }
}