diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index f9ccb45..41b436d 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -261,14 +261,14 @@ public static function processDatetime(&$element, FormStateInterface $form_state $element['date'] = array( '#type' => 'date', - '#title' => t('Date'), - '#title_display' => 'invisible', + '#title' => $element['#title'], '#value' => $date_value, '#attributes' => $element['#attributes'] + $extra_attributes, '#required' => $element['#required'], '#size' => max(12, strlen($element['#value']['date'])), '#error_no_message' => TRUE, '#date_date_format' => $element['#date_date_format'], + '#states' => $element['#states'], ); // Allows custom callbacks to alter the element. @@ -292,15 +292,22 @@ public static function processDatetime(&$element, FormStateInterface $form_state 'type' => $element['#date_time_element'], 'step' => $element['#date_increment'], ); + $time_title = t('Time'); + $time_title_display = 'invisible'; + if ($element['#date_date_element'] == 'none') { + $time_title = $element['#title']; + $time_title_display = 'before'; + } $element['time'] = array( '#type' => 'date', - '#title' => t('Time'), - '#title_display' => 'invisible', + '#title' => $time_title, + '#title_display' => $time_title_display, '#value' => $time_value, '#attributes' => $element['#attributes'] + $extra_attributes, '#required' => $element['#required'], '#size' => 12, '#error_no_message' => TRUE, + '#states' => $element['#states'], ); // Allows custom callbacks to alter the element. @@ -313,6 +320,8 @@ public static function processDatetime(&$element, FormStateInterface $form_state } } + unset($element['#title']); + return $element; }