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
a1f849404c
commit
bd272a4ca8
|
@ -35,7 +35,11 @@ class TimestampDatetimeWidget extends WidgetBase {
|
|||
'#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 @@ class TimestampTest extends BrowserTestBase {
|
|||
'field_storage' => $this->fieldStorage,
|
||||
'bundle' => 'entity_test',
|
||||
'required' => TRUE,
|
||||
'description' => 'Description for timestamp field.',
|
||||
]);
|
||||
$this->field->save();
|
||||
|
||||
|
@ -114,6 +115,9 @@ class TimestampTest extends BrowserTestBase {
|
|||
// 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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue