You are here

function date_views_form_views_exposed_form_alter in Date 7.3

Same name and namespace in other branches
  1. 7.2 date_views/date_views.module \date_views_form_views_exposed_form_alter()

Implements hook_form_FORM_ID_alter() for views_exposed_form().

File

date_views/date_views.module, line 469
Date Views module.

Code

function date_views_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  $children = element_children($form);

  // @todo On a stock views_exposed_form, there won't be any grandchildren
  // items, but will this always be the case? How about better_exposed_filters?
  foreach ($children as $child) {
    if (isset($form[$child]['#id']) && strpos($form[$child]['#id'], 'date_views_exposed_filter-') === 0) {

      // Remove empty or scalar date input when an array was expected.
      if (empty($form_state['input'][$child]) || !is_array($form_state['input'][$child])) {
        unset($form_state['input'][$child]);
      }
      elseif (empty($form_state['input'][$child]['value']) || !is_array($form_state['input'][$child]['value'])) {
        unset($form_state['input'][$child]['value']);
      }
    }
  }
}