public function DateRangeDatelistWidget::settingsForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDatelistWidget.php \Drupal\datetime_range\Plugin\Field\FieldWidget\DateRangeDatelistWidget::settingsForm()
- 9 core/modules/datetime_range/src/Plugin/Field/FieldWidget/DateRangeDatelistWidget.php \Drupal\datetime_range\Plugin\Field\FieldWidget\DateRangeDatelistWidget::settingsForm()
Returns a form to configure settings for the widget.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form definition for the widget settings.
Overrides WidgetBase::settingsForm
File
- core/
modules/ datetime_range/ src/ Plugin/ Field/ FieldWidget/ DateRangeDatelistWidget.php, line 96
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('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;
}