function DateTimeDatelistWidget::settingsForm
Same name in other branches
- 8.9.x core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget::settingsForm()
- 10 core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget::settingsForm()
- 11.x core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget::settingsForm()
Overrides WidgetBase::settingsForm
File
-
core/
modules/ datetime/ src/ Plugin/ Field/ FieldWidget/ DateTimeDatelistWidget.php, line 91
Class
- DateTimeDatelistWidget
- Plugin implementation of the 'datetime_datelist' widget.
Namespace
Drupal\datetime\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') == '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('5 minute'),
10 => $this->t('10 minute'),
15 => $this->t('15 minute'),
30 => $this->t('30 minute'),
],
];
}
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.