You are here

trait MinSearchLengthTrait in Select2 Boxes 8

Trait MinSearchLengthTrait.

@package Drupal\select2boxes

Hierarchy

2 files declare their use of MinSearchLengthTrait
Select2BoxesAutocompleteListWidget.php in src/Plugin/Field/FieldWidget/Select2BoxesAutocompleteListWidget.php
SingleSelect2BoxesAutocompleteWidget.php in src/Plugin/Field/FieldWidget/SingleSelect2BoxesAutocompleteWidget.php

File

src/MinSearchLengthTrait.php, line 10

Namespace

Drupal\select2boxes
View source
trait MinSearchLengthTrait {

  /**
   * Limit search input visibility by results length.
   *
   * @param array $attributes
   *   Element attributes array.
   */
  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;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MinSearchLengthTrait::limitSearchByMinLength protected function Limit search input visibility by results length.