function DateTimeFieldItemList::defaultValuesForm
Same name in other branches
- 9 core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php \Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList::defaultValuesForm()
- 8.9.x core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php \Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList::defaultValuesForm()
- 11.x core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php \Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList::defaultValuesForm()
Overrides FieldItemList::defaultValuesForm
1 call to DateTimeFieldItemList::defaultValuesForm()
- DateRangeFieldItemList::defaultValuesForm in core/
modules/ datetime_range/ src/ Plugin/ Field/ FieldType/ DateRangeFieldItemList.php - Returns a form for the default value input.
1 method overrides DateTimeFieldItemList::defaultValuesForm()
- DateRangeFieldItemList::defaultValuesForm in core/
modules/ datetime_range/ src/ Plugin/ Field/ FieldType/ DateRangeFieldItemList.php - Returns a form for the default value input.
File
-
core/
modules/ datetime/ src/ Plugin/ Field/ FieldType/ DateTimeFieldItemList.php, line 29
Class
- DateTimeFieldItemList
- Represents a configurable entity datetime field.
Namespace
Drupal\datetime\Plugin\Field\FieldTypeCode
public function defaultValuesForm(array &$form, FormStateInterface $form_state) {
if (empty($this->getFieldDefinition()
->getDefaultValueCallback())) {
$default_value = $this->getFieldDefinition()
->getDefaultValueLiteral();
$element = [
'#parents' => [
'default_value_input',
],
'default_date_type' => [
'#type' => 'select',
'#title' => $this->t('Default date'),
'#description' => $this->t('Set a default value for this date.'),
'#default_value' => $default_value[0]['default_date_type'] ?? '',
'#options' => [
static::DEFAULT_VALUE_NOW => $this->t('Current date'),
static::DEFAULT_VALUE_CUSTOM => $this->t('Relative date'),
],
'#empty_value' => '',
],
'default_date' => [
'#type' => 'textfield',
'#title' => $this->t('Relative default value'),
'#description' => $this->t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"http://php.net/manual/function.strtotime.php\">strtotime</a> for more details."),
'#default_value' => isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM ? $default_value[0]['default_date'] : '',
'#states' => [
'visible' => [
':input[id="edit-default-value-input-default-date-type"]' => [
'value' => static::DEFAULT_VALUE_CUSTOM,
],
],
],
],
];
return $element;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.