Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment