class Select2 in Select 2 8
Same name in this branch
- 8 src/Element/Select2.php \Drupal\select2\Element\Select2
- 8 src/Plugin/better_exposed_filters/filter/Select2.php \Drupal\select2\Plugin\better_exposed_filters\filter\Select2
Select2 widget implementation.
Plugin annotation
@BetterExposedFiltersFilterWidget(
id = "bef_select2",
label = @Translation("Select2"),
)
Hierarchy
- class \Drupal\select2\Plugin\better_exposed_filters\filter\Select2 extends \Drupal\better_exposed_filters\Plugin\better_exposed_filters\filter\FilterWidgetBase
Expanded class hierarchy of Select2
2 string references to 'Select2'
- select2.info.yml in ./
select2.info.yml - select2.info.yml
- select2.schema.yml in config/
schema/ select2.schema.yml - config/schema/select2.schema.yml
File
- src/
Plugin/ better_exposed_filters/ filter/ Select2.php, line 16
Namespace
Drupal\select2\Plugin\better_exposed_filters\filterView source
class Select2 extends FilterWidgetBase {
/**
* {@inheritdoc}
*/
public function exposedFormAlter(array &$form, FormStateInterface $form_state) {
$field_id = $this
->getExposedFilterFieldId();
parent::exposedFormAlter($form, $form_state);
if (!empty($form[$field_id])) {
$filter = $this->handler;
$form[$field_id]['#type'] = 'select2';
$form[$field_id]['#autocomplete'] = !empty($filter->options['type']) && $filter->options['type'] === 'textfield';
$form[$field_id]['#multiple'] = !empty($filter->options['expose']['multiple']) && $filter->options['expose']['multiple'];
$form[$field_id]['#select2'] = [
'width' => '100%',
'allowClear' => FALSE,
];
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Select2:: |
public | function |