public function BootstrapDateRangeWidget::settingsSummary in Bootstrap DateTime Picker 2.0.x
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/ BootstrapDateRangeWidget.php, line 101
Class
- BootstrapDateRangeWidget
- Plugin implementation of the BootstrapDateTimeWidget widget.
Namespace
Drupal\bootstrap_datetime_picker\Plugin\Field\FieldWidgetCode
public function settingsSummary() {
$summary = [];
$summary[] = t('Hours Format: @hour_format', [
'@hour_format' => $this
->getSetting('hour_format'),
]);
$summary[] = t('Minutes Granularity: @allow_times', [
'@allow_times' => $this
->getSetting('allow_times'),
]);
$options = [
'1' => $this
->t('Monday'),
'2' => $this
->t('Tuesday'),
'3' => $this
->t('Wednesday'),
'4' => $this
->t('Thursday'),
'5' => $this
->t('Friday'),
'6' => $this
->t('Saturday'),
'7' => $this
->t('Sunday'),
];
$disabled_days = [];
foreach ($this
->getSetting('disable_days') as $key => $value) {
if (!empty($value)) {
$disabled_days[] = $options[$value];
}
}
$disabled_days = implode(',', $disabled_days);
$summary[] = t('Disabled days: @disabled_days', [
'@disabled_days' => !empty($disabled_days) ? $disabled_days : t('None'),
]);
$summary[] = t('Disabled dates: @disabled_dates', [
'@disabled_dates' => !empty($this
->getSetting('exclude_date')) ? $this
->getSetting('exclude_date') : t('None'),
]);
return $summary;
}