diff --git a/date_admin.inc b/date_admin.inc index 993aa09..ff9eb50 100644 --- a/date_admin.inc +++ b/date_admin.inc @@ -229,7 +229,15 @@ function _date_field_instance_settings_form($field, $instance) { '#weight' => 2.1, '#fieldset' => 'default_values', ); - + // Display element description instance setting for date popup. + if ($widget['type'] == 'date_popup') { + $form['show_element_description'] = array( + '#type' => 'checkbox', + '#title' => t('Show date elements description'), + '#default_value' => isset($settings['show_element_description']) ? $settings['show_element_description'] : FALSE, + '#description' => t('Current date (and time) as placeholder if there is no value set.'), + ); + } $form['#element_validate'] = array('date_field_instance_settings_form_validate'); $context = array( diff --git a/date_popup/date_popup.module b/date_popup/date_popup.module index ca292ef..9943f68 100644 --- a/date_popup/date_popup.module +++ b/date_popup/date_popup.module @@ -288,6 +288,11 @@ function date_popup_element_process($element, &$form_state, $form) { 'event' => 'change', ); } + // Display date element description setting. + if (isset($element['#instance'])) { + $element['#show_element_description'] = isset($element['#instance']['settings']['show_element_description']) ? $element['#instance']['settings']['show_element_description'] : FALSE; + } + $element['#show_element_description'] = isset($element['#show_element_description']) ? $element['#show_element_description'] : FALSE; $element['date'] = date_popup_process_date_part($element); $element['time'] = date_popup_process_time_part($element); @@ -364,8 +369,10 @@ function date_popup_process_date_part(&$element) { '#ajax' => !empty($element['#ajax']) ? $element['#ajax'] : FALSE, ); $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' => date_format_date(date_example_date(), 'custom', date_popup_date_format($element)))); + // Display date element description as placeholder. + if (!empty($element['#show_element_description'])) { + $sub_element['#attributes']['placeholder'] = date_format_date(date_example_date(), 'custom', date_popup_date_format($element)); + } return $sub_element; } @@ -440,10 +447,12 @@ function date_popup_process_time_part(&$element) { $sub_element['#value'] = $sub_element['#default_value']; - // TODO, figure out exactly when we want this description. In many places it is not desired. $example_date = date_now(); date_increment_round($example_date, $element['#date_increment']); - $sub_element['#description'] = t('E.g., @date', array('@date' => date_format_date($example_date, 'custom', date_popup_time_format($element)))); + // Display date element description as placeholder. + if (!empty($element['#show_element_description'])) { + $sub_element['#attributes']['placeholder'] = date_format_date(date_example_date(), 'custom', date_popup_time_format($element)); + } return ($sub_element); } diff --git a/date_views/includes/date_views_filter_handler_simple.inc b/date_views/includes/date_views_filter_handler_simple.inc index 8a46253..227df1b 100644 --- a/date_views/includes/date_views_filter_handler_simple.inc +++ b/date_views/includes/date_views_filter_handler_simple.inc @@ -39,9 +39,26 @@ class date_views_filter_handler_simple extends views_handler_filter_date { $options['default_to_date'] = array('default' => ''); $options['year_range'] = array('default' => '-3:+3'); $options['add_delta'] = array('default' => ''); + $options['expose']['contains']['show_element_description'] = array('default' => 0); return $options; } + function expose_form(&$form, &$form_state) { + parent::expose_form($form, $form_state); + + // Display element description setting for date popup. + if ($this->options['form_type'] == 'date_popup') { + $form['expose'] += array( + 'show_element_description' => array( + '#type' => 'checkbox', + '#title' => t('Show date elements description'), + '#default_value' => $this->options['expose']['show_element_description'], + '#description' => t('Current date (and time) as placeholder if there is no value set.'), + ), + ); + } + } + /** * Helper function to find a default value. */ @@ -335,6 +352,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date { '#process' => array($type . '_element_process'), '#prefix' => '
', '#suffix' => '
', + '#show_element_description' => $this->options['expose']['show_element_description'], ); if ($which == 'all') { $form[$prefix]['#pre_render'][] = 'ctools_dependent_pre_render'; @@ -375,6 +393,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date { ":input.{$prefix}-choose-input-type" => array('value' => 'date'), ), ), + '#show_element_description' => TRUE, ); $form[$prefix . '_group'][$relative_id] = array( '#type' => 'textfield', @@ -392,6 +411,7 @@ class date_views_filter_handler_simple extends views_handler_filter_date { $form[$prefix . '_group']['#dependency'] = array($source => $operator_values); } } + return $form; }