Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The date_popup field widget always adds its own description field to the form, irrespective of the presence of one specified in the form array.
The following change will suppress the default description added by the date_popup module if a description is already present.
File "date_popup.module", line 312
$sub_element['#description'] = ' '. t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', $date_format)));
should be changed to:
if (!isset($element['#description'])) {
$sub_element['#description'] = ' '. t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', $date_format)));
and, line 349
$sub_element['#description'] = t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', $time_format)));
should be similarly changed to:
if (!isset($element['#description'])) {
$sub_element['#description'] = t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', $time_format)));
I am not sure whether the $element['#description'] variable should be unset. It does not seem to cause problems at my site anyway.
Comments
Comment #1
jlscott CreditAttribution: jlscott commentedCorrection: My last comment should have read:
"I don't know whether the original "$element['#description']" should have been added to the sub-element, and unset from the element."
Comment #2
magnusk CreditAttribution: magnusk commentedIs there a way to not display that default description?
Comment #3
kleinmp CreditAttribution: kleinmp commentedIt was difficult to find a way to not display this, so I ended up resorting to patching the date_popup module at the same place as the above comment with the following:
That way I could display or not display the format on a field by field basis based on whether I set '#date_format_display' to FALSE. By default, it still shows the format in the description.
Comment #4
KarenS CreditAttribution: KarenS commentedI want to make some changes here to give you more control over whether or when those descriptions are displayed. I will probably add a theme that you can override.
Comment #5
KarenS CreditAttribution: KarenS commentedSee #1244458: Better handling for the date format descriptions. Let's merge these ideas into that issue.