You are here

protected function FilterWidgetBase::getExposedFilterWidgetType in Better Exposed Filters 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php \Drupal\better_exposed_filters\Plugin\better_exposed_filters\filter\FilterWidgetBase::getExposedFilterWidgetType()

Helper function to get the widget type of the exposed filter.

Return value

string The type of the form render element use for the exposed filter.

1 call to FilterWidgetBase::getExposedFilterWidgetType()
FilterWidgetBase::buildConfigurationForm in src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php
Form constructor.

File

src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php, line 328

Class

FilterWidgetBase
Base class for Better exposed filters widget plugins.

Namespace

Drupal\better_exposed_filters\Plugin\better_exposed_filters\filter

Code

protected function getExposedFilterWidgetType() {

  // We need to dig into the exposed form configuration to retrieve the
  // form type of the filter.
  $form = [];
  $form_state = new FormState();
  $form_state
    ->set('exposed', TRUE);

  /** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
  $filter = $this->handler;
  $filter
    ->buildExposedForm($form, $form_state);
  $filter_id = $filter->options['expose']['identifier'];
  return $form[$filter_id]['#type'] ?? $form[$filter_id]['value']['#type'] ?? '';
}