You are here

protected function MinSearchLengthTrait::limitSearchByMinLength in Select2 Boxes 8

Limit search input visibility by results length.

Parameters

array $attributes: Element attributes array.

2 calls to MinSearchLengthTrait::limitSearchByMinLength()
Select2BoxesAutocompleteListWidget::formElement in src/Plugin/Field/FieldWidget/Select2BoxesAutocompleteListWidget.php
Returns the form for a single field widget.
SingleSelect2BoxesAutocompleteWidget::formElement in src/Plugin/Field/FieldWidget/SingleSelect2BoxesAutocompleteWidget.php
Returns the form for a single field widget.

File

src/MinSearchLengthTrait.php, line 18

Class

MinSearchLengthTrait
Trait MinSearchLengthTrait.

Namespace

Drupal\select2boxes

Code

protected function limitSearchByMinLength(array &$attributes) {
  $config = \Drupal::config('select2boxes.settings');
  if ($config
    ->get('limited_search') == '1') {
    $length = $config
      ->get('minimum_search_length') ?: 0;
    $attributes['data-minimum-search-length'] = $length;
  }
}