function DateTimeDatelistWidget::settingsForm
Same name in other branches
- 9 core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php \Drupal\datetime\Plugin\Field\FieldWidget\DateTimeDatelistWidget::settingsForm()
- 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()
Overrides WidgetBase::settingsForm
File
-
core/
modules/ datetime/ src/ Plugin/ Field/ FieldWidget/ DateTimeDatelistWidget.php, line 75
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('@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.