Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
|
@ -23,16 +23,16 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultSettings() {
|
||||
return array(
|
||||
return [
|
||||
'date_format' => DATETIME_DATETIME_STORAGE_FORMAT,
|
||||
) + parent::defaultSettings();
|
||||
] + parent::defaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
$output = '';
|
||||
|
|
@ -76,12 +76,12 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
|
|||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$form = parent::settingsForm($form, $form_state);
|
||||
|
||||
$form['date_format'] = array(
|
||||
$form['date_format'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Date/time format'),
|
||||
'#description' => $this->t('See <a href="http://php.net/manual/function.date.php" target="_blank">the documentation for PHP date formats</a>.'),
|
||||
'#default_value' => $this->getSetting('date_format'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultSettings() {
|
||||
return array(
|
||||
return [
|
||||
'format_type' => 'medium',
|
||||
) + parent::defaultSettings();
|
||||
] + parent::defaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
$output = '';
|
||||
|
|
@ -56,7 +56,7 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
}
|
||||
|
||||
// Display the date using theme datetime.
|
||||
$elements[$delta] = array(
|
||||
$elements[$delta] = [
|
||||
'#cache' => [
|
||||
'contexts' => [
|
||||
'timezone',
|
||||
|
|
@ -65,10 +65,10 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
'#theme' => 'time',
|
||||
'#text' => $output,
|
||||
'#html' => FALSE,
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'datetime' => $iso_date,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
if (!empty($item->_attributes)) {
|
||||
$elements[$delta]['#attributes'] += $item->_attributes;
|
||||
// Unset field item attributes since they have been included in the
|
||||
|
|
@ -100,17 +100,17 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
$format_types = $this->dateFormatStorage->loadMultiple();
|
||||
$options = [];
|
||||
foreach ($format_types as $type => $type_info) {
|
||||
$format = $this->dateFormatter->format($time->format('U'), $type);
|
||||
$format = $this->dateFormatter->format($time->getTimestamp(), $type);
|
||||
$options[$type] = $type_info->label() . ' (' . $format . ')';
|
||||
}
|
||||
|
||||
$form['format_type'] = array(
|
||||
$form['format_type'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Date format'),
|
||||
'#description' => t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."),
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->getSetting('format_type'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
$summary = parent::settingsSummary();
|
||||
|
||||
$date = new DrupalDateTime();
|
||||
$summary[] = t('Format: @display', array('@display' => $this->formatDate($date, $this->getFormatSettings())));
|
||||
$summary[] = t('Format: @display', ['@display' => $this->formatDate($date, $this->getFormatSettings())]);
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultSettings() {
|
||||
return array(
|
||||
return [
|
||||
'timezone_override' => '',
|
||||
) + parent::defaultSettings();
|
||||
] + parent::defaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,13 +93,13 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
|
|||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$form = parent::settingsForm($form, $form_state);
|
||||
|
||||
$form['timezone_override'] = array(
|
||||
$form['timezone_override'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Time zone override'),
|
||||
'#description' => $this->t('The time zone selected here will always be used'),
|
||||
'#options' => system_time_zones(TRUE),
|
||||
'#default_value' => $this->getSetting('timezone_override'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ abstract class DateTimeFormatterBase extends FormatterBase implements ContainerF
|
|||
$summary = parent::settingsSummary();
|
||||
|
||||
if ($override = $this->getSetting('timezone_override')) {
|
||||
$summary[] = $this->t('Time zone: @timezone', array('@timezone' => $override));
|
||||
$summary[] = $this->t('Time zone: @timezone', ['@timezone' => $override]);
|
||||
}
|
||||
|
||||
return $summary;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class DateTimePlainFormatter extends DateTimeFormatterBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
$output = '';
|
||||
|
|
|
|||
|
|
@ -74,11 +74,11 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultSettings() {
|
||||
$settings = array(
|
||||
$settings = [
|
||||
'future_format' => '@interval hence',
|
||||
'past_format' => '@interval ago',
|
||||
'granularity' => 2,
|
||||
) + parent::defaultSettings();
|
||||
] + parent::defaultSettings();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
$date = $item->date;
|
||||
|
|
@ -128,26 +128,26 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
|
|||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$form = parent::settingsForm($form, $form_state);
|
||||
|
||||
$form['future_format'] = array(
|
||||
$form['future_format'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Future format'),
|
||||
'#default_value' => $this->getSetting('future_format'),
|
||||
'#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['past_format'] = array(
|
||||
$form['past_format'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Past format'),
|
||||
'#default_value' => $this->getSetting('past_format'),
|
||||
'#description' => $this->t('Use <em>@interval</em> where you want the formatted interval text to appear.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['granularity'] = array(
|
||||
$form['granularity'] = [
|
||||
'#type' => 'number',
|
||||
'#title' => $this->t('Granularity'),
|
||||
'#default_value' => $this->getSetting('granularity'),
|
||||
'#description' => $this->t('How many time units should be shown in the formatted output.'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
@ -160,8 +160,8 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory
|
|||
|
||||
$future_date = new DrupalDateTime('1 year 1 month 1 week 1 day 1 hour 1 minute');
|
||||
$past_date = new DrupalDateTime('-1 year -1 month -1 week -1 day -1 hour -1 minute');
|
||||
$summary[] = t('Future date: %display', array('%display' => $this->formatDate($future_date)));
|
||||
$summary[] = t('Past date: %display', array('%display' => $this->formatDate($past_date)));
|
||||
$summary[] = t('Future date: %display', ['%display' => $this->formatDate($future_date)]);
|
||||
$summary[] = t('Past date: %display', ['%display' => $this->formatDate($past_date)]);
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,31 +30,31 @@ class DateTimeFieldItemList extends FieldItemList {
|
|||
if (empty($this->getFieldDefinition()->getDefaultValueCallback())) {
|
||||
$default_value = $this->getFieldDefinition()->getDefaultValueLiteral();
|
||||
|
||||
$element = array(
|
||||
'#parents' => array('default_value_input'),
|
||||
'default_date_type' => array(
|
||||
$element = [
|
||||
'#parents' => ['default_value_input'],
|
||||
'default_date_type' => [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default date'),
|
||||
'#description' => t('Set a default value for this date.'),
|
||||
'#default_value' => isset($default_value[0]['default_date_type']) ? $default_value[0]['default_date_type'] : '',
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
static::DEFAULT_VALUE_NOW => t('Current date'),
|
||||
static::DEFAULT_VALUE_CUSTOM => t('Relative date'),
|
||||
),
|
||||
],
|
||||
'#empty_value' => '',
|
||||
),
|
||||
'default_date' => array(
|
||||
],
|
||||
'default_date' => [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Relative default value'),
|
||||
'#description' => 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' => array(
|
||||
'visible' => array(
|
||||
':input[id="edit-default-value-input-default-date-type"]' => array('value' => static::DEFAULT_VALUE_CUSTOM),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
'#states' => [
|
||||
'visible' => [
|
||||
':input[id="edit-default-value-input-default-date-type"]' => ['value' => static::DEFAULT_VALUE_CUSTOM],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ class DateTimeFieldItemList extends FieldItemList {
|
|||
*/
|
||||
public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state) {
|
||||
if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_CUSTOM) {
|
||||
$is_strtotime = @strtotime($form_state->getValue(array('default_value_input', 'default_date')));
|
||||
$is_strtotime = @strtotime($form_state->getValue(['default_value_input', 'default_date']));
|
||||
if (!$is_strtotime) {
|
||||
$form_state->setErrorByName('default_value_input][default_date', t('The relative date value entered is invalid.'));
|
||||
}
|
||||
|
|
@ -76,13 +76,13 @@ class DateTimeFieldItemList extends FieldItemList {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) {
|
||||
if ($form_state->getValue(array('default_value_input', 'default_date_type'))) {
|
||||
if ($form_state->getValue(array('default_value_input', 'default_date_type')) == static::DEFAULT_VALUE_NOW) {
|
||||
if ($form_state->getValue(['default_value_input', 'default_date_type'])) {
|
||||
if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_NOW) {
|
||||
$form_state->setValueForElement($element['default_date'], static::DEFAULT_VALUE_NOW);
|
||||
}
|
||||
return array($form_state->getValue('default_value_input'));
|
||||
return [$form_state->getValue('default_value_input')];
|
||||
}
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -108,12 +108,12 @@ class DateTimeFieldItemList extends FieldItemList {
|
|||
// We only provide a default value for the first item, as do all fields.
|
||||
// Otherwise, there is no way to clear out unwanted values on multiple value
|
||||
// fields.
|
||||
$default_value = array(
|
||||
array(
|
||||
$default_value = [
|
||||
[
|
||||
'value' => $value,
|
||||
'date' => $date,
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
}
|
||||
return $default_value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ class DateTimeItem extends FieldItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultStorageSettings() {
|
||||
return array(
|
||||
return [
|
||||
'datetime_type' => 'datetime',
|
||||
) + parent::defaultStorageSettings();
|
||||
] + parent::defaultStorageSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,37 +63,37 @@ class DateTimeItem extends FieldItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function schema(FieldStorageDefinitionInterface $field_definition) {
|
||||
return array(
|
||||
'columns' => array(
|
||||
'value' => array(
|
||||
return [
|
||||
'columns' => [
|
||||
'value' => [
|
||||
'description' => 'The date value.',
|
||||
'type' => 'varchar',
|
||||
'length' => 20,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'value' => array('value'),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'value' => ['value'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
|
||||
$element = array();
|
||||
$element = [];
|
||||
|
||||
$element['datetime_type'] = array(
|
||||
$element['datetime_type'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Date type'),
|
||||
'#description' => t('Choose the type of date to create.'),
|
||||
'#default_value' => $this->getSetting('datetime_type'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
static::DATETIME_TYPE_DATETIME => t('Date and time'),
|
||||
static::DATETIME_TYPE_DATE => t('Date only'),
|
||||
),
|
||||
],
|
||||
'#disabled' => $has_data,
|
||||
);
|
||||
];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultSettings() {
|
||||
return array(
|
||||
return [
|
||||
'increment' => '15',
|
||||
'date_order' => 'YMD',
|
||||
'time_type' => '24',
|
||||
) + parent::defaultSettings();
|
||||
] + parent::defaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -35,6 +35,9 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
|
||||
$element = parent::formElement($items, $delta, $element, $form, $form_state);
|
||||
|
||||
// Wrap all of the select elements with a fieldset.
|
||||
$element['#theme_wrappers'][] = 'fieldset';
|
||||
|
||||
$date_order = $this->getSetting('date_order');
|
||||
|
||||
if ($this->getFieldSetting('datetime_type') == 'datetime') {
|
||||
|
|
@ -49,35 +52,35 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
// Set up the date part order array.
|
||||
switch ($date_order) {
|
||||
case 'YMD':
|
||||
$date_part_order = array('year', 'month', 'day');
|
||||
$date_part_order = ['year', 'month', 'day'];
|
||||
break;
|
||||
|
||||
case 'MDY':
|
||||
$date_part_order = array('month', 'day', 'year');
|
||||
$date_part_order = ['month', 'day', 'year'];
|
||||
break;
|
||||
|
||||
case 'DMY':
|
||||
$date_part_order = array('day', 'month', 'year');
|
||||
$date_part_order = ['day', 'month', 'year'];
|
||||
break;
|
||||
}
|
||||
switch ($time_type) {
|
||||
case '24':
|
||||
$date_part_order = array_merge($date_part_order, array('hour', 'minute'));
|
||||
$date_part_order = array_merge($date_part_order, ['hour', 'minute']);
|
||||
break;
|
||||
|
||||
case '12':
|
||||
$date_part_order = array_merge($date_part_order, array('hour', 'minute', 'ampm'));
|
||||
$date_part_order = array_merge($date_part_order, ['hour', 'minute', 'ampm']);
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
break;
|
||||
}
|
||||
|
||||
$element['value'] = array(
|
||||
$element['value'] = [
|
||||
'#type' => 'datelist',
|
||||
'#date_increment' => $increment,
|
||||
'#date_part_order' => $date_part_order,
|
||||
) + $element['value'];
|
||||
] + $element['value'];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
|
@ -85,23 +88,23 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$element = parent::settingsForm($form, $form_state);
|
||||
|
||||
$element['date_order'] = array(
|
||||
$element['date_order'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Date part order'),
|
||||
'#default_value' => $this->getSetting('date_order'),
|
||||
'#options' => array('MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')),
|
||||
);
|
||||
'#options' => ['MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')],
|
||||
];
|
||||
|
||||
if ($this->getFieldSetting('datetime_type') == 'datetime') {
|
||||
$element['time_type'] = array(
|
||||
$element['time_type'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Time type'),
|
||||
'#default_value' => $this->getSetting('time_type'),
|
||||
'#options' => array('24' => t('24 hour time'), '12' => t('12 hour time')),
|
||||
);
|
||||
'#options' => ['24' => t('24 hour time'), '12' => t('12 hour time')],
|
||||
];
|
||||
|
||||
$element['increment'] = [
|
||||
'#type' => 'select',
|
||||
|
|
@ -117,10 +120,10 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
];
|
||||
}
|
||||
else {
|
||||
$element['time_type'] = array(
|
||||
$element['time_type'] = [
|
||||
'#type' => 'hidden',
|
||||
'#value' => 'none',
|
||||
);
|
||||
];
|
||||
|
||||
$element['increment'] = [
|
||||
'#type' => 'hidden',
|
||||
|
|
@ -135,12 +138,12 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function settingsSummary() {
|
||||
$summary = array();
|
||||
$summary = [];
|
||||
|
||||
$summary[] = t('Date part order: @order', array('@order' => $this->getSetting('date_order')));
|
||||
$summary[] = t('Date part order: @order', ['@order' => $this->getSetting('date_order')]);
|
||||
if ($this->getFieldSetting('datetime_type') == 'datetime') {
|
||||
$summary[] = t('Time type: @time_type', array('@time_type' => $this->getSetting('time_type')));
|
||||
$summary[] = t('Time increments: @increment', array('@increment' => $this->getSetting('increment')));
|
||||
$summary[] = t('Time type: @time_type', ['@time_type' => $this->getSetting('time_type')]);
|
||||
$summary[] = t('Time increments: @increment', ['@increment' => $this->getSetting('increment')]);
|
||||
}
|
||||
|
||||
return $summary;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,16 @@ class DateTimeDefaultWidget extends DateTimeWidgetBase implements ContainerFacto
|
|||
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
|
||||
$element = parent::formElement($items, $delta, $element, $form, $form_state);
|
||||
|
||||
// If the field is date-only, make sure the title is displayed. Otherwise,
|
||||
// wrap everything in a fieldset, and the title will be shown in the legend.
|
||||
if ($this->getFieldSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE) {
|
||||
$element['value']['#title'] = $this->fieldDefinition->getLabel();
|
||||
$element['value']['#description'] = $this->fieldDefinition->getDescription();
|
||||
}
|
||||
else {
|
||||
$element['#theme_wrappers'][] = 'fieldset';
|
||||
}
|
||||
|
||||
// Identify the type of date and time elements to use.
|
||||
switch ($this->getFieldSetting('datetime_type')) {
|
||||
case DateTimeItem::DATETIME_TYPE_DATE:
|
||||
|
|
@ -76,14 +86,14 @@ class DateTimeDefaultWidget extends DateTimeWidgetBase implements ContainerFacto
|
|||
break;
|
||||
}
|
||||
|
||||
$element['value'] += array(
|
||||
$element['value'] += [
|
||||
'#date_date_format' => $date_format,
|
||||
'#date_date_element' => $date_type,
|
||||
'#date_date_callbacks' => array(),
|
||||
'#date_date_callbacks' => [],
|
||||
'#date_time_format' => $time_format,
|
||||
'#date_time_element' => $time_type,
|
||||
'#date_time_callbacks' => array(),
|
||||
);
|
||||
'#date_time_callbacks' => [],
|
||||
];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,22 +17,13 @@ class DateTimeWidgetBase extends WidgetBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
|
||||
// We are nesting some sub-elements inside the parent, so we need a wrapper.
|
||||
// We also need to add another #title attribute at the top level for ease in
|
||||
// identifying this item in error messages. We do not want to display this
|
||||
// title because the actual title display is handled at a higher level by
|
||||
// the Field module.
|
||||
|
||||
$element['#theme_wrappers'][] = 'datetime_wrapper';
|
||||
$element['#attributes']['class'][] = 'container-inline';
|
||||
|
||||
$element['value'] = array(
|
||||
$element['value'] = [
|
||||
'#type' => 'datetime',
|
||||
'#default_value' => NULL,
|
||||
'#date_increment' => 1,
|
||||
'#date_timezone' => drupal_get_user_timezone(),
|
||||
'#required' => $element['#required'],
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) {
|
||||
// A date-only field should have no timezone conversion performed, so
|
||||
|
|
|
|||
Reference in a new issue