You are here

public function Select2EntityReferenceWidget::settingsSummary in Select 2 8

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides Select2Widget::settingsSummary

File

src/Plugin/Field/FieldWidget/Select2EntityReferenceWidget.php, line 138

Class

Select2EntityReferenceWidget
Plugin implementation of the 'select2' widget.

Namespace

Drupal\select2\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $autocomplete = $this
    ->getSetting('autocomplete');
  $operators = $this
    ->getMatchOperatorOptions();
  $summary[] = $this
    ->t('Autocomplete: @autocomplete', [
    '@autocomplete' => $autocomplete ? $this
      ->t('On') : $this
      ->t('Off'),
  ]);
  if ($autocomplete) {
    $summary[] = $this
      ->t('Autocomplete matching: @match_operator', [
      '@match_operator' => $operators[$this
        ->getSetting('match_operator')],
    ]);
    $size = $this
      ->getSetting('match_limit') ?: $this
      ->t('unlimited');
    $summary[] = $this
      ->t('Autocomplete suggestion list size: @size', [
      '@size' => $size,
    ]);
  }
  return $summary;
}