I have created a module to use date_popup on views filter. It works ok with just one date, but fails when applied to "between" operator (but only if both fields are changed, no error if I just change MAX or MIN). Here is my code: <?php function views_filter_date_popup_form_views_ui_config_item_form_alter(&$form, $form_state) { if ('2' != substr(views_api_version(), 0, 1)) { // Only continue for Views 2.x return; } if (!empty($form['options']['expose'])) { if (isset($form['options']['value']['type']['#options']) && array_key_exists('date', $form['options']['value']['type']['#options'])) { $form['options']['value']['type']['#options']['user_defined_date'] = t('A user defined data using PHP date() wildcards'); $form['options']['value']['date_format'] = array( '#type' => 'textfield', '#title' => t('Date_format'), '#default_value' => !empty($form_state['handler']->options['value']['date_format']) ? $form_state['handler']->options['value']['date_format'] : 'Y/m/d', ); } } } function views_filter_date_popup_form_views_exposed_form_alter(&$form, $form_state) { foreach ($form_state['view']->filter as $field => $filter) { if ($filter->options['value']['type']=='user_defined_date') { switch($filter->options['operator']) { case 'between': $form[$filter->options['id']]['min']['#type'] = 'date_popup'; $form[$filter->options['id']]['min']['#size'] = '20'; //YYYY-MM-DD HH:MM:SS $form[$filter->options['id']]['min']['#date_format'] = $filter->options['value']['date_format']; $form[$filter->options['id']]['max']['#type'] = 'date_popup'; $form[$filter->options['id']]['max']['#size'] = '20'; //YYYY-MM-DD HH:MM:SS $form[$filter->options['id']]['max']['#date_format'] = $filter->options['value']['date_format']; break; default: $form[$filter->options['id']]['#type'] = 'date_popup'; $form[$filter->options['id']]['#size'] = '20'; //YYYY-MM-DD HH:MM:SS $form[$filter->options['id']]['#date_format'] = $filter->options['value']['date_format']; break; } } } } The error is: warning: strtotime() expects parameter 1 to be string, array given in /home/lluisforns/workspace/comptacau2/sites/all/modules/views/handlers/views_handler_filter_date.inc on line 128. Any hint? -- *La vida no ha de ser feliç, ha de ser plena. *Abans d'imprimir aquest missatge, pensa en el medi ambient.
participants (1)
-
Lluís Forns