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

jlscott’s picture

Correction: 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."

magnusk’s picture

Version: 6.x-2.7 » 7.x-2.x-dev

Is there a way to not display that default description?

kleinmp’s picture

It 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:

if (!isset($element['#date_format_display']) || $element['#date_format_display']) {
  $sub_element['#description'] = ' '. t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', date_popup_date_format($element))));
}

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.

KarenS’s picture

Title: Extra description text for date_popup field » More control over format examples in description

I 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.

KarenS’s picture

Status: Active » Closed (duplicate)

See #1244458: Better handling for the date format descriptions. Let's merge these ideas into that issue.