You are here

public function EntityReferenceAutocompleteWidget::settingsSummary in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget::settingsSummary()

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 WidgetBase::settingsSummary

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php, line 74

Class

EntityReferenceAutocompleteWidget
Plugin implementation of the 'entity_reference_autocomplete' widget.

Namespace

Drupal\Core\Field\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $operators = $this
    ->getMatchOperatorOptions();
  $summary[] = 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,
  ]);
  $summary[] = t('Textfield size: @size', [
    '@size' => $this
      ->getSetting('size'),
  ]);
  $placeholder = $this
    ->getSetting('placeholder');
  if (!empty($placeholder)) {
    $summary[] = t('Placeholder: @placeholder', [
      '@placeholder' => $placeholder,
    ]);
  }
  else {
    $summary[] = t('No placeholder');
  }
  return $summary;
}