You are here

public function BetterExposedFilters::buildOptionsForm in Better Exposed Filters 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/views/exposed_form/BetterExposedFilters.php \Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters::buildOptionsForm()
  2. 8.4 src/Plugin/views/exposed_form/BetterExposedFilters.php \Drupal\better_exposed_filters\Plugin\views\exposed_form\BetterExposedFilters::buildOptionsForm()

@inheritdoc

Overrides InputRequired::buildOptionsForm

File

src/Plugin/views/exposed_form/BetterExposedFilters.php, line 30

Class

BetterExposedFilters
Exposed form plugin that provides a basic exposed form.

Namespace

Drupal\better_exposed_filters\Plugin\views\exposed_form

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $bef_options = array();

  // Get current settings and default values for new filters/
  $existing = $this
    ->getSettings();

  // Insert a checkbox to make the input required optional just before the
  // input required text field. Only show the text field if the input required
  // option is selected.
  $textInputRequired = $form['text_input_required'];
  unset($form['text_input_required']);
  $form['input_required'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Input required'),
    '#description' => $this
      ->t('Only display results after the user has selected a filter option.'),
    '#default_value' => !empty($this->options['input_required']),
  ];
  $form['text_input_required'] = $textInputRequired += [
    '#states' => [
      'visible' => [
        'input[name="exposed_form_options[input_required]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];

  /*
   * Add general options for exposed form items.
   */
  $bef_options['general']['allow_secondary'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable secondary exposed form options'),
    '#default_value' => $existing['general']['allow_secondary'],
    '#description' => $this
      ->t('Allows you to specify some exposed form elements as being secondary options and places those elements in a collapsible "details" element. Use this option to place some exposed filters in an "Advanced Search" area of the form, for example.'),
  );
  $bef_options['general']['secondary_label'] = array(
    '#type' => 'textfield',
    '#default_value' => $existing['general']['secondary_label'],
    '#title' => $this
      ->t('Secondary options label'),
    '#description' => $this
      ->t('The name of the details element to hold secondary options. This cannot be left blank or there will be no way to show/hide these options.'),
    '#states' => array(
      'required' => array(
        ':input[name="exposed_form_options[bef][general][allow_secondary]"]' => array(
          'checked' => TRUE,
        ),
      ),
      'visible' => array(
        ':input[name="exposed_form_options[bef][general][allow_secondary]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );

  // Add the 'autosbumit' functionality from Views 7.x.
  $bef_options['general']['autosubmit'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Autosubmit'),
    '#description' => $this
      ->t('Automatically submit the form once an element is changed.'),
    '#default_value' => $existing['general']['autosubmit'],
  );
  $bef_options['general']['autosubmit_exclude_textfield'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Exclude Textfield'),
    '#description' => $this
      ->t('Exclude Textfield from autosubmit. User will have to press enter key or click submit.'),
    '#default_value' => $existing['general']['autosubmit_exclude_textfield'],
    '#states' => array(
      'visible' => array(
        ':input[name="exposed_form_options[bef][general][autosubmit]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $bef_options['general']['autosubmit_textfield_delay'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Delay for textfield autosubmit'),
    '#description' => $this
      ->t('Configure a delay in ms before triggering autosubmit on textfields.'),
    '#default_value' => $existing['general']['autosubmit_textfield_delay'],
    '#states' => array(
      'visible' => array(
        ':input[name="exposed_form_options[bef][general][autosubmit]"]' => array(
          'checked' => TRUE,
        ),
        ':input[name="exposed_form_options[bef][general][autosubmit_exclude_textfield]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $bef_options['general']['autosubmit_hide'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide submit button'),
    '#description' => $this
      ->t('Hide submit button if javascript is enabled.'),
    '#default_value' => $existing['general']['autosubmit_hide'],
    '#states' => array(
      'visible' => array(
        ':input[name="exposed_form_options[bef][general][autosubmit]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );

  /*
   * Add options for exposed sorts.
   */
  $exposed = FALSE;

  /* @var \Drupal\views\Plugin\views\HandlerBase $sort */
  foreach ($this->view->display_handler
    ->getHandlers('sort') as $label => $sort) {
    if ($sort
      ->isExposed()) {
      $exposed = TRUE;
      break;
    }
  }
  if ($exposed) {
    $bef_options['sort']['bef_format'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Display exposed sort options as'),
      '#default_value' => $existing['sort']['bef_format'],
      '#options' => array(
        'default' => $this
          ->t('Default Views element'),
        'bef' => $this
          ->t('Radio Buttons'),
        'bef_links' => $this
          ->t('Links'),
      ),
      '#description' => $this
        ->t('Select a format for the exposed sort options.'),
    );
    $bef_options['sort']['advanced'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Advanced sort options'),
    );
    $bef_options['sort']['advanced']['collapsible'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Make sort options collapsible'),
      '#default_value' => $existing['sort']['advanced']['collapsible'],
      '#description' => $this
        ->t('Puts the sort options in a collapsible details element.'),
    );
    $bef_options['sort']['advanced']['collapsible_label'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Collapsible details element title'),
      '#default_value' => empty($existing['sort']['advanced']['collapsible_label']) ? $this
        ->t('Sort options') : $existing['sort']['advanced']['collapsible_label'],
      '#description' => $this
        ->t('This cannot be left blank or there will be no way to show/hide sort options.'),
      '#states' => array(
        'visible' => array(
          ':input[name="exposed_form_options[bef][sort][advanced][collapsible]"]' => array(
            'checked' => TRUE,
          ),
        ),
        'required' => array(
          ':input[name="exposed_form_options[bef][sort][advanced][collapsible]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );

    // We can only combine sort order and sort by if both options are exposed.
    $bef_options['sort']['advanced']['combine'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Combine sort order with sort by'),
      '#default_value' => $existing['sort']['advanced']['combine'],
      '#description' => $this
        ->t('Combines the sort by options and order (ascending or decending) into a single list.  Use this to display "Option1 (ascending)", "Option1 (descending)", "Option2 (ascending)", "Option2 (descending)" in a single form element. Sort order should first be exposed by selecting <em>Allow people to choose the sort order</em>.'),
      '#states' => [
        'enabled' => [
          ':input[name="exposed_form_options[expose_sort_order]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    );
    $bef_options['sort']['advanced']['combine_rewrite'] = array(
      '#type' => 'textarea',
      '#title' => $this
        ->t('Rewrite the text displayed'),
      '#default_value' => $existing['sort']['advanced']['combine_rewrite'],
      '#description' => $this
        ->t('Use this field to rewrite the text displayed for combined sort options and sort order. Use the format of current_text|replacement_text, one replacement per line. For example: <pre>
Post date Asc|Oldest first
Post date Desc|Newest first
Title Asc|A -> Z
Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option altogether. The order the options appear will be changed to match the order of options in this field.'),
      '#states' => array(
        'visible' => array(
          ':input[name="exposed_form_options[bef][sort][advanced][combine]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $bef_options['sort']['advanced']['reset'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Include a "Reset sort" option'),
      '#default_value' => $existing['sort']['advanced']['reset'],
      '#description' => $this
        ->t('Adds a "Reset sort" link; Views will use the default sort order.'),
    );
    $bef_options['sort']['advanced']['reset_label'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('"Reset sort" label'),
      '#default_value' => $existing['sort']['advanced']['reset_label'],
      '#description' => $this
        ->t('This cannot be left blank if the above option is checked'),
      '#states' => array(
        'visible' => array(
          ':input[name="exposed_form_options[bef][sort][advanced][reset]"]' => array(
            'checked' => TRUE,
          ),
        ),
        'required' => array(
          ':input[name="exposed_form_options[bef][sort][advanced][reset]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $bef_options['sort']['advanced']['is_secondary'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('This is a secondary option'),
      '#default_value' => $existing['sort']['advanced']['is_secondary'],
      '#states' => array(
        'visible' => array(
          ':input[name="exposed_form_options[bef][general][allow_secondary]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#description' => $this
        ->t('Places this element in the secondary options portion of the exposed form.'),
    );
  }

  /*
   * Add options for exposed pager.
   */
  if (isset($this->display->display_options['pager']) && $this->display->display_options['pager']['options']['expose']['items_per_page']) {
    $bef_options['pager']['bef_format'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Display exposed pager options as'),
      '#default_value' => $existing['pager']['bef_format'],
      '#options' => array(
        'default' => $this
          ->t('Default (Views render element)'),
        'bef' => $this
          ->t('Radio Buttons'),
        'bef_links' => $this
          ->t('Links'),
      ),
      '#description' => $this
        ->t('Select a format for the exposed pager options.'),
    );
    $bef_options['pager']['is_secondary'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('This is a secondary option'),
      '#default_value' => $existing['pager']['is_secondary'],
      '#states' => array(
        'visible' => array(
          ':input[name="exposed_form_options[bef][general][allow_secondary]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#description' => $this
        ->t('Places this element in the secondary options portion of the exposed form.'),
    );
  }

  // Only add the description text once -- it was getting a little long to be
  // added to each filter.
  $bef_filter_intro = FALSE;

  // Go through each filter and add BEF options.

  /* @var \Drupal\views\Plugin\views\HandlerBase $filter */
  foreach ($this->view->display_handler
    ->getHandlers('filter') as $label => $filter) {
    if (!$filter
      ->isExposed()) {
      continue;
    }

    // If we're adding BEF filter options, add an intro to explain what's
    // going on.
    if (!$bef_filter_intro) {
      $bef_options['bef_intro'] = array(
        '#markup' => '<h3>' . $this
          ->t('Exposed Filter Settings') . '</h3><p>' . $this
          ->t('This section lets you select additional options for exposed filters. Some options are only available in certain situations. If you do not see the options you expect, please see the <a href=":link">BEF settings documentation page</a> for more details.', array(
          ':link' => Url::fromUri('http://drupal.org/node/1701012')
            ->toString(),
        )) . '</p>',
      );
      $bef_filter_intro = TRUE;
    }

    // These filter operators get our standard options: select, radio or
    // checkboxes, links, etc.
    $bef_standard = FALSE;

    // These filters get a single on/off checkbox option for boolean
    // operators.
    $bef_single = FALSE;

    // Used for taxonomy filters with hierarchy.
    $bef_nested = FALSE;

    // Used for taxonomy filters with hierarchy rendered as links.
    $bef_nested_links = FALSE;

    // Used for date-based filters.
    $bef_datepicker = FALSE;

    // Used for numeric, non-date filters.
    $bef_slider = FALSE;

    // Check various filter types and determine what options are available.
    if (is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\StringFilter') || is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
      if (in_array($filter->operator, array(
        'in',
        'or',
        'and',
      ))) {
        $bef_standard = TRUE;
      }
      if (in_array($filter->operator, array(
        'empty',
        'not empty',
      ))) {
        $bef_standard = TRUE;
        if (!$filter->options['expose']['multiple']) {
          $bef_single = TRUE;
        }
      }
    }
    if (is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\BooleanOperator')) {
      $bef_standard = TRUE;
      if (!$filter->options['expose']['multiple']) {
        $bef_single = TRUE;
      }
    }
    if (is_a($filter, 'Drupal\\taxonomy\\Plugin\\views\\filter\\TaxonomyIndexTid')) {

      // Autocomplete and dropdown taxonomy filter are both instances of
      // TaxonomyIndexTid, but we can't show BEF options for the autocomplete
      // widget.
      if ($this->displayHandler->handlers['filter'][$label]->options['type'] != 'select') {
        $bef_standard = FALSE;
      }
      elseif (!empty($this->displayHandler->handlers['filter'][$label]->options['hierarchy'])) {
        $bef_nested = TRUE;
        $bef_nested_links = TRUE;
      }
    }
    if (is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\Date') || !empty($filter->date_handler)) {
      $bef_datepicker = TRUE;
    }

    // The date filter handler extends the numeric filter handler so we have
    // to exclude it specifically.
    if (is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\NumericFilter') && !is_a($filter, 'Drupal\\views\\Plugin\\views\\filter\\Date')) {
      $bef_slider = TRUE;
    }

    // All filters can use the default filter exposed by Views.
    $display_options = array(
      'default' => $this
        ->t('Default (Views render element)'),
    );
    if ($bef_standard) {

      // Main BEF option: radios/checkboxes.
      $display_options['bef'] = $this
        ->t('Checkboxes/Radio Buttons');
    }
    if ($bef_nested) {
      $display_options['bef_ul'] = $this
        ->t('Nested Checkboxes/Radio Buttons');
    }
    if ($bef_single) {
      $display_options['bef_single'] = $this
        ->t('Single on/off checkbox');
    }
    if ($bef_datepicker) {
      $display_options['bef_datepicker'] = $this
        ->t('jQuery UI Datepicker');
    }
    if ($bef_slider) {
      $display_options['bef_slider'] = $this
        ->t('jQuery UI slider');
    }
    if ($bef_standard) {

      // Less used BEF options, so put them last.
      $display_options['bef_links'] = $this
        ->t('Links');
      if ($bef_nested_links) {
        $display_options['bef_ul_links'] = $this
          ->t('Nested Links');
      }
      $display_options['bef_hidden'] = $this
        ->t('Hidden');
    }

    // Alter the list of available display options for this filter.
    \Drupal::moduleHandler()
      ->alter('better_exposed_filters_display_options', $display_options, $filter);
    $identifier = '"' . $filter->options['expose']['identifier'] . '"';
    if (!empty($filter->options['expose']['label'])) {
      $identifier .= $this
        ->t(' (Filter label: "@fl")', array(
        '@fl' => $filter->options['expose']['label'],
      ));
    }
    $bef_options[$label]['bef_format'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Display @identifier exposed filter as', array(
        '@identifier' => $identifier,
      )),
      '#default_value' => $existing[$label]['bef_format'],
      '#options' => $display_options,
    );
    if ($bef_slider) {

      // Details element for jQuery slider options.
      $bef_options[$label]['slider_options'] = array(
        '#type' => 'details',
        '#title' => $this
          ->t('Slider options for @identifier', array(
          '@identifier' => $identifier,
        )),
        '#open' => TRUE,
        '#states' => array(
          'visible' => array(
            ':input[name="exposed_form_options[bef][' . $label . '][bef_format]"]' => array(
              'value' => 'bef_slider',
            ),
          ),
        ),
      );
      $bef_options[$label]['slider_options']['bef_slider_min'] = array(
        '#type' => 'textfield',
        '#title' => $this
          ->t('Range minimum'),
        '#default_value' => $this->options['bef'][$label]['slider_options']['bef_slider_min'],
        '#bef_filter_id' => $label,
        '#states' => array(
          'required' => array(
            ':input[name="exposed_form_options[bef][' . $label . '][bef_format]"]' => array(
              'value' => 'bef_slider',
            ),
          ),
        ),
        '#description' => $this
          ->t('The minimum allowed value for the jQuery range slider. It can be positive, negative, or zero and have up to 11 decimal places.'),
      );
      $bef_options[$label]['slider_options']['bef_slider_max'] = array(
        '#type' => 'textfield',
        '#title' => $this
          ->t('Range maximum'),
        '#default_value' => $this->options['bef'][$label]['slider_options']['bef_slider_max'],
        '#bef_filter_id' => $label,
        '#states' => array(
          'required' => array(
            ':input[name="exposed_form_options[bef][' . $label . '][bef_format]"]' => array(
              'value' => 'bef_slider',
            ),
          ),
        ),
        '#description' => $this
          ->t('The maximum allowed value for the jQuery range slider. It can be positive, negative, or zero and have up to 11 decimal places.'),
      );
      $bef_options[$label]['slider_options']['bef_slider_step'] = array(
        '#type' => 'textfield',
        '#title' => $this
          ->t('Step'),
        '#default_value' => empty($this->options['bef'][$label]['slider_options']['bef_slider_step']) ? 1 : $this->options['bef'][$label]['slider_options']['bef_slider_step'],
        '#bef_filter_id' => $label,
        '#states' => array(
          'required' => array(
            ':input[name="exposed_form_options[bef][' . $label . '][bef_format]"]' => array(
              'value' => 'bef_slider',
            ),
          ),
        ),
        '#description' => $this
          ->t('Determines the size or amount of each interval or step the slider takes between the min and max.') . '<br />' . $this
          ->t('The full specified value range of the slider (Range maximum - Range minimum) must be evenly divisible by the step.') . '<br />' . $this
          ->t('The step must be a positive number of up to 5 decimal places.'),
      );
      $bef_options[$label]['slider_options']['bef_slider_animate'] = array(
        '#type' => 'textfield',
        '#title' => $this
          ->t('Animate'),
        '#default_value' => $this->options['bef'][$label]['slider_options']['bef_slider_animate'],
        '#bef_filter_id' => $label,
        '#description' => $this
          ->t('Whether to slide handle smoothly when user click outside handle on the bar. Allowed values are "slow", "normal", "fast" or the number of milliseconds to run the animation (e.g. 1000). If left blank, there will be no animation, the slider will just jump to the new value instantly.'),
      );
      $bef_options[$label]['slider_options']['bef_slider_orientation'] = array(
        '#type' => 'select',
        '#title' => $this
          ->t('Orientation'),
        '#options' => array(
          'horizontal' => $this
            ->t('Horizontal'),
          'vertical' => $this
            ->t('Vertical'),
        ),
        '#default_value' => $this->options['bef'][$label]['slider_options']['bef_slider_orientation'],
        '#bef_filter_id' => $label,
        '#states' => array(
          'required' => array(
            ':input[name="exposed_form_options[bef][' . $label . '][bef_format]"]' => array(
              'value' => 'bef_slider',
            ),
          ),
        ),
        '#description' => $this
          ->t('The orientation of the jQuery range slider.'),
      );
    }

    // Details element to keep the UI from getting out of hand.
    $bef_options[$label]['more_options'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('More options for @identifier', array(
        '@identifier' => $identifier,
      )),
    );

    // Select all checkbox.
    if ($bef_standard) {
      $bef_options[$label]['more_options']['bef_select_all_none'] = array(
        '#type' => 'checkbox',
        '#title' => $this
          ->t('Add select all/none links'),
        '#default_value' => $existing[$label]['more_options']['bef_select_all_none'],
        '#disabled' => !$filter->options['expose']['multiple'],
        '#description' => $this
          ->t('Add a "Select All/None" link when rendering the exposed filter using
              checkboxes. If this option is disabled, edit the filter and check the
              "Allow multiple selections".'),
      );
      if ($bef_nested) {
        $bef_options[$label]['more_options']['bef_select_all_none_nested'] = array(
          '#type' => 'checkbox',
          '#title' => $this
            ->t('Add nested all/none selection'),
          '#default_value' => $this->options['bef'][$label]['more_options']['bef_select_all_none_nested'],
          '#disabled' => !$filter->options['expose']['multiple'] || !$filter->options['hierarchy'],
          '#description' => $this
            ->t('When a parent checkbox is checked, check all its children. If this option
                is disabled, edit the filter and check "Allow multiple selections" and
                edit the filter settings and check "Show hierarchy in dropdown".'),
        );
      }

      // Put filter in details element option.
      // TODO: expand to all exposed filters.
      $bef_options[$label]['more_options']['bef_collapsible'] = array(
        '#type' => 'checkbox',
        '#title' => $this
          ->t('Make this filter collapsible'),
        '#default_value' => $existing[$label]['more_options']['bef_collapsible'],
        '#description' => $this
          ->t('Puts this filter in a collapsible details element'),
      );
    }

    // Allow any filter to be moved into the secondary options element.
    $bef_options[$label]['more_options']['is_secondary'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('This is a secondary option'),
      '#default_value' => $existing[$label]['more_options']['is_secondary'],
      '#states' => array(
        'visible' => array(
          ':input[name="exposed_form_options[bef][general][allow_secondary]"]' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#description' => $this
        ->t('Places this element in the secondary options portion of the exposed form.'),
    );
    $filter_form = array();
    $form_state = new FormState();

    // Let form plugins know this is for exposed widgets.
    $form_state
      ->set('exposed', TRUE);

    /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
    $filter
      ->buildExposedForm($filter_form, $form_state);
    $supported_types = array(
      'entity_autocomplete',
      'textfield',
    );
    $filter_id = $filter->options['expose']['identifier'];
    if (isset($filter_form[$filter_id]['#type']) && in_array($filter_form[$filter_id]['#type'], $supported_types) || isset($filter_form[$filter_id]['value']) && in_array($filter_form[$filter_id]['value']['#type'], $supported_types)) {

      // Allow users to specify placeholder text.
      $bef_options[$label]['more_options']['placeholder_text'] = [
        '#type' => 'textfield',
        '#title' => $this
          ->t('Placeholder text'),
        '#description' => $this
          ->t('Text to be shown in the text field until it is edited. Leave blank for no placeholder to be set.'),
        '#default_value' => $existing[$label]['more_options']['placeholder_text'],
      ];
    }

    // Allow rewriting of filter options for any filter. String and numeric
    // filters allow unlimited filter options via textfields, so we can't
    // offer rewriting for those.
    // @TODO: check other core filter types to see if there are others that
    // should be added to this list.
    if (!$filter instanceof StringFilter && !$filter instanceof NumericFilter) {
      $bef_options[$label]['more_options']['rewrite'] = array(
        '#title' => $this
          ->t('Rewrite filter options'),
        '#type' => 'details',
      );
      $bef_options[$label]['more_options']['rewrite']['filter_rewrite_values'] = array(
        '#type' => 'textarea',
        '#title' => $this
          ->t('Rewrite the text displayed'),
        '#default_value' => $existing[$label]['more_options']['rewrite']['filter_rewrite_values'],
        '#description' => $this
          ->t('Use this field to rewrite the filter options displayed. Use the format of current_text|replacement_text, one replacement per line. For example: <pre>
  Current|Replacement
  On|Yes
  Off|No
  </pre> Leave the replacement text blank to remove an option altogether. If using hierarchical taxonomy filters, do not including leading hyphens in the current text.
          '),
      );
    }
  }

  /* Ends: foreach ($filters as $filter) { */

  // Add BEF form elements to the exposed form options form.
  $form['bef'] = $bef_options;
}