function DateRangeDatelistWidget::settingsForm
Same name in other branches
- 9 core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDatelistWidget.php \Drupal\datetime_range\Plugin\Field\FieldWidget\DateRangeDatelistWidget::settingsForm()
- 8.9.x core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDatelistWidget.php \Drupal\datetime_range\Plugin\Field\FieldWidget\DateRangeDatelistWidget::settingsForm()
- 10 core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDatelistWidget.php \Drupal\datetime_range\Plugin\Field\FieldWidget\DateRangeDatelistWidget::settingsForm()
Overrides WidgetBase::settingsForm
File
-
core/
modules/ datetime_range/ src/ Plugin/ Field/ FieldWidget/ DateRangeDatelistWidget.php, line 95
Class
- DateRangeDatelistWidget
- Plugin implementation of the 'daterange_datelist' widget.
Namespace
Drupal\datetime_range\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$element['date_order'] = [
'#type' => 'select',
'#title' => $this->t('Date part order'),
'#default_value' => $this->getSetting('date_order'),
'#options' => [
'MDY' => $this->t('Month/Day/Year'),
'DMY' => $this->t('Day/Month/Year'),
'YMD' => $this->t('Year/Month/Day'),
],
];
if ($this->getFieldSetting('datetime_type') == DateRangeItem::DATETIME_TYPE_DATETIME) {
$element['time_type'] = [
'#type' => 'select',
'#title' => $this->t('Time type'),
'#default_value' => $this->getSetting('time_type'),
'#options' => [
'24' => $this->t('24 hour time'),
'12' => $this->t('12 hour time'),
],
];
$element['increment'] = [
'#type' => 'select',
'#title' => $this->t('Time increments'),
'#default_value' => $this->getSetting('increment'),
'#options' => [
1 => $this->t('1 minute'),
5 => $this->t('@count minutes', [
'@count' => 5,
]),
10 => $this->t('@count minutes', [
'@count' => 10,
]),
15 => $this->t('@count minutes', [
'@count' => 15,
]),
30 => $this->t('@count minutes', [
'@count' => 30,
]),
],
];
}
else {
$element['time_type'] = [
'#type' => 'hidden',
'#value' => 'none',
];
$element['increment'] = [
'#type' => 'hidden',
'#value' => $this->getSetting('increment'),
];
}
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.