Unverified Commit ea33b157 authored by alexpott's avatar alexpott
Browse files

Issue #2672950 by Vj, ilya.no, Krzysztof Domański, elandirayan, Rijidij,...

Issue #2672950 by Vj, ilya.no, Krzysztof Domański, elandirayan, Rijidij, amateescu, shahgm, larowlan: Notice: Undefined index: #default_value in Drupal\Core\Datetime\Element\Datetime::valueCallback() (line 103
parent d1c7fa1b
......@@ -96,7 +96,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
];
}
else {
$date = $element['#default_value'];
$date = isset($element['#default_value']) ? $element['#default_value'] : NULL;
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
$input = [
'date' => $date->format($element['#date_date_format']),
......
......@@ -64,6 +64,15 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#date_date_callbacks' => [[$this, 'datetimecallback']],
];
// Element without specifying the default value.
$form['simple_datetime_element'] = [
'#type' => 'datetime',
'#date_date_format' => ['Y-m-d'],
'#date_time_format' => ['H:i:s'],
'#date_date_element' => 'HTML Date',
'#date_time_element' => 'HTML Time',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment