public function ReadonlyFieldWidget::settingsSummary in Read-only Field Widget 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/ ReadonlyFieldWidget.php, line 189
Class
- ReadonlyFieldWidget
- Plugin implementation of the 'readonly_field_widget' widget.
Namespace
Drupal\readonly_field_widget\Plugin\Field\FieldWidgetCode
public function settingsSummary() {
$formatters = $this->fieldFormatterManager
->getOptions($this->fieldDefinition
->getType());
$label_options = $this
->labelOptions();
$plugin = $this
->getFormatterInstance();
if ($plugin) {
$summary = $plugin
->settingsSummary();
$formatter_type = $this
->getSetting('formatter_type');
if (isset($formatters[$formatter_type])) {
$summary[] = t('Format: @format', [
'@format' => $formatters[$formatter_type],
]);
}
}
$summary[] = t('Label: @label', [
'@label' => $label_options[$this
->getSetting('label')],
]);
$summary[] = t('Show Description: @show_desc', [
'@show_desc' => $this
->getSetting('show_description') ? $this
->t('Yes') : $this
->t('No'),
]);
return $summary;
}