Commit bd272a4c authored by catch's avatar catch
Browse files

Issue #2508866 by paulocs, slashrsm, raman.b, vakulrai, justanothermark,...

Issue #2508866 by paulocs, slashrsm, raman.b, vakulrai, justanothermark, kishor_kolekar, KapilV, ranjith_kumar_k_u, Rinku Jacob 13, AndrewTur, quietone, pameeela, alexpott, catch: Field description is not displayed with Timestamp datetime widget
parent a1f84940
Loading
Loading
Loading
Loading
+5 −1
Changes for core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -35,7 +35,11 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
      '#default_value' => $default_value,
      '#date_year_range' => '1902:2037',
    ];
    $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', ['%format' => Datetime::formatExample($date_format . ' ' . $time_format)]);

    $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;
  }
+4 −0
Changes for core/tests/Drupal/FunctionalTests/Datetime/TimestampTest.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ protected function setUp(): void {
      'field_storage' => $this->fieldStorage,
      'bundle' => 'entity_test',
      'required' => TRUE,
      'description' => 'Description for timestamp field.',
    ]);
    $this->field->save();

@@ -114,6 +115,9 @@ public function testWidget() {
    // Display creation form.
    $this->drupalGet('entity_test/add');

    // Make sure the field description is properly displayed.
    $this->assertSession()->pageTextContains('Description for timestamp field.');

    // Make sure the "datetime_timestamp" widget is on the page.
    $this->assertSession()->elementsCount('xpath', '//div[contains(@class, "field--widget-datetime-timestamp") and @id="edit-field-timestamp-wrapper"]', 1);