How to remove format description in date_popup form field? How can I remove format description in date_popup form field?

$form['payable_by'] = array(
    '#type' =&gt; 'date_popup',
    '#title' =&gt; $amount !== '' ? t('Instalment payable date for instalment @label', array('@label' =&gt; $amount)) : t('Instalment payable date for new instalment'),
    '#title_display' =&gt; 'invisible',
    '#default_value' =&gt; $payable_by,
    '#parents' =&gt; array('instalment', $key, 'payable_by'),
        '#date_format' =&gt; 'Y-m-d',
        '#date_year_range' =&gt; '-0:+1',
  );


Please check the image
Normally, you would just set the #description property of the form element, and it would be rendered. With the date_popup element implemented by the Date module it seems it is not possible: The form element is made of two sub-elements for which the value of the #description property is not taken into consideration.

As there are two branches, I will report what I have noticed in the development snapshot for both the branches.

Branch 7.x-2

The "date_popup" element is defined with the following code.

function date_popup_element_info() {
  $timepicker = date_popup_get_preferred_timepicker();
  $type['date_popup'] = array(
    '#input' =&gt; TRUE,
    '#tree' =&gt; TRUE,
    '#date_timezone' =&gt; date_default_timezone(),
    '#date_flexible' =&gt; 0,
    '#date_format' =&gt; variable_get('date_format_short', 'm/d/Y - H:i'),
    '#timepicker' =&gt; variable_get('date_popup_timepicker', $timepicker),
    '#date_increment' =&gt; 1,
    '#date_year_range' =&gt; '-3:+3',
    '#date_label_position' =&gt; 'above',
    '#process' =&gt; array('date_popup_element_process'),
    '#value_callback' =&gt; 'date_popup_element_value_callback',
    '#theme_wrappers' =&gt; array('date_popup'),
  );
  if (module_exists('ctools')) {
    $type['date_popup']['#pre_render'] = array('ctools_dependent_pre_render');
  }
  return $type;
}


The element has a process function that execute the following code.

  $element['#tree'] = TRUE;
  $element['#theme_wrappers'] = array('date_popup');

  if (!empty($element['#ajax'])) {
    $element['#ajax'] += array(
      'trigger_as' =&gt; array('name' =&gt;$element['#name']),
      'event' =&gt; 'change',
    );
  }

  $element['date'] = date_popup_process_date_part($element);
  $element['time'] = date_popup_process_time_part($element);


Looking at the code for date_popup_process_date_part(), I notice the following code.

  $sub_element['#value'] = $sub_element['#default_value'];
  // TODO, figure out exactly when we want this description. In many places it is not desired.
  $sub_element['#description'] = ' '. t('E.g., @date', array('@date' =&gt; date_format_date(date_now(), 'custom', date_popup_date_format($element))));


As the code that date_popup_element_process() executes before to return the element is the following one, there is still an alternative.

  $context = array(
   'form' =&gt; $form,
  );
  drupal_alter('date_popup_process', $element, $form_state, $context);


Implementing hook_date_popup_process_alter() you could remove the description.

function mymodule_date_popup_process_alter(&amp;$element, &amp;$form_state, $context) {
  unset($element['date']['#description']);
  unset($element['time']['#description']);
}


Similar code is present in the branch 6.x-2.

Branch 7.x-1

There are few differences with the branch I previously described. (See the code repository.)

The first is the code that in date_popup_process_date_part() sets the description, which is the following one.

  $sub_element['#value'] = $sub_element['#default_value'];
  // TODO, figure out exactly when we want this description. In many places it is not desired.
  $sub_element['#description'] = ' '. t('Format: @date', array('@date' =&gt; date_format_date(date_now(), 'custom', date_popup_date_format($element))));
  return $sub_element;


The second difference is that date_popup_element_process() (the process function for that element) is not invoking hook_date_popup_process_alter().

function date_popup_element_process($element, $form_state, $form) {
  date_popup_add();
  module_load_include('inc', 'date_api', 'date_api_elements');

  $element['#tree'] = TRUE;
  $element['#theme_wrappers'] = array('date_popup');

  $element['date'] = date_popup_process_date($element);
  $element['time'] = date_popup_process_time($element);

  if (isset($element['#element_validate'])) {
    array_push($element['#element_validate'], 'date_popup_validate');
  }
  else {
    $element['#element_validate'] = array('date_popup_validate');
  }
  return $element;
}


The only alternative in this case would be to implement hook_element_info_alter() to add a process function to the element.

function mymodule_element_info_alter(&amp;$type) {
  if (isset($type['date_popup'])) {
    $type['date_popup']['#process'][] = 'mymodule_date_popup_process';
  }
}

function mymodule_date_popup_process($element, $form_state, $complete_form) {
  unset($element['date']['#description']);
  unset($element['time']['#description']);

  return $element;
}


The code for branch 6.x-1 is similar to the code of branch 6.x-2.

&nbsp; 

In both the cases, the comment reported in the Date module code suggests they will alter the code not to use the description that is now shown. For this reason, I would suggest to implement the necessary code in a custom module, and remove that code once the Date module is changed.