diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index c8dd4d1b03696bb98ae9b18ca69702ade4527f40..3a016b558021642a62a8cc34e437c474807312c7 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -227,11 +227,13 @@ function template_preprocess_datetime_wrapper(&$variables) { $element = $variables['element']; // If the element is required, a required marker is appended to the label. - $form_required_marker = array( - '#theme' => 'form_required_marker', - '#element' => $element, - ); - $variables['required'] = !empty($element['#required']) ? drupal_render($form_required_marker) : ''; + $variables['required'] = NULL; + if(!empty($element['#required'])) { + $variables['required'] = array( + '#theme' => 'form_required_marker', + '#element' => $element, + ); + } if (!empty($element['#title'])) { $variables['title'] = $element['#title']; diff --git a/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php index ec62ca3dcfbd7b502d9d2f65e3e0f82c989db8ef..76b4cb962f2fa2558e9dcdd5a528d2c541cb0915 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php @@ -69,7 +69,6 @@ function setUp() { 'field_name' => $this->field->name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - 'required' => TRUE, )); $this->instance->save(); @@ -98,7 +97,6 @@ function testDateField() { // Display creation form. $this->drupalGet('entity_test/add'); $this->assertFieldByName("{$field_name}[0][value][date]", '', 'Date element found.'); - $this->assertFieldByXPath('//*[@id="' . $field_name . '-add-more-wrapper"]/h4/span', '*', 'Required markup found'); $this->assertNoFieldByName("{$field_name}[0][value][time]", '', 'Time element not found.'); // Submit a valid date and ensure it is accepted.