$time_format = DateFormat::
load('html_time'
)->
getPattern();
$default_value =
isset($items[$delta]->value
) ? DrupalDateTime::
createFromTimestamp($items[$delta]->value
) : '';
$element['value'
] =
$element +
[ '#type' => 'datetime',
'#default_value' =>
$default_value,
'#date_year_range' => '1902:2037',
];
$element['value'
]['#description'
] =
$element['#description'
] !== ''
?
$element['#description'
] :
$this->
t('Format: %format. Leave blank to use the time of form submission.',
['%format' => Datetime::
formatExample($date_format . ' ' .
$time_format)]);
return $element;
} /**
* {@inheritdoc}
*/
public function massageFormValues(array
$values, array
$form, FormStateInterface
$form_state) { foreach ($values as &
$item) { // @todo The structure is different whether access is denied or not, to
// be fixed in https://www.drupal.org/node/2326533.