You are here

public function LanguageSelectWidget::settingsSummary in Custom Language field 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 WidgetBase::settingsSummary

File

src/Plugin/Field/FieldWidget/LanguageSelectWidget.php, line 56

Class

LanguageSelectWidget
Plugin implementation of the 'language_select' widget.

Namespace

Drupal\languagefield\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $settings = $this
    ->getSettings()['format'];
  $options = LanguageItem::settingsOptions('widget');
  if (empty($settings)) {
    $summary[] = $this
      ->t('** Not set **');
    return $summary;
  }
  foreach ($settings as $value) {
    switch ($value) {
      case '0':

        // Option is not selected.
        break;
      default:
        $summary[] = isset($options[$value]) ? $options[$value] : '...';
        break;
    }
  }
  return $summary;
}