Commit 12d2fa86 authored by Taras Kruts's avatar Taras Kruts
Browse files

Merge pull request #2920 from goalgorilla/bugfix/3278469-select2-isnt-working-for-bef

Issue #3278469 by alex.ksis: Made social tagging filters compatible with Select2 and Better exposed filters
parent 8769c6c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ dependencies:
  - drupal:taxonomy
  - social:social_core
  - social:social_search
  - select2:select2
+13 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Database\Database;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;
use Drupal\select2\Element\Select2;

/**
 * Implements hook_help().
@@ -522,6 +523,18 @@ function social_tagging_form_views_exposed_form_alter(&$form, FormStateInterface
        $form[$label]['#type'] = 'select2';
        $form[$label]['#size'] = NULL;

        if (isset($form[$label]['#context']['#plugin_type']) && $form[$label]['#context']['#plugin_type'] === 'bef') {
          $form[$label]['#select2'] = [];
          $form[$label]['#process'] = [
            [Select2::class, 'processSelect'],
          ];
          $form[$label]['#pre_render'] = [
            [Select2::class, 'preRenderSelect'],
            [Select2::class, 'preRenderAutocomplete'],
            [Select2::class, 'preRenderOverwrites'],
          ];
        }

        /** @var \Symfony\Component\HttpFoundation\ParameterBag $query */
        $query = \Drupal::request()->query;
        if ($query->has($label)) {