You are here

function hs_taxonomy_views_handler_filter_term_node_tid::exposed_validate in Hierarchical Select 6.3

Validate the exposed filter form

File

modules/hs_taxonomy_views_handler_filter_term_node_tid.inc, line 190
This file defines a new filter handler for using Hierarchical Select in exposed Taxonomy term filters.

Class

hs_taxonomy_views_handler_filter_term_node_tid
@file This file defines a new filter handler for using Hierarchical Select in exposed Taxonomy term filters.

Code

function exposed_validate($form, &$form_state) {

  // No validation necessary when the filter is not exposed or when no
  // identifier is set.
  if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) {
    return;
  }
  if (!$this
    ->select_type_is_hierarchical_select()) {
    parent::exposed_validate($form, $form_state);
  }
  else {
    $identifier = $this->options['expose']['identifier'];
    $input = $form_state['values'][$identifier];

    // If the HS_TAXONOMY_VIEWS_ANY_OPTION option is selected, then the
    // results should not be filtered at all.
    if (!is_array($input)) {

      // When filtering by multiple terms.
      if ($input != HS_TAXONOMY_VIEWS_ANY_OPTION) {
        $this->validated_exposed_input = $input;
      }
    }
    else {

      // When filtering by a single term.
      if (!in_array(HS_TAXONOMY_VIEWS_ANY_OPTION, $input)) {
        $this->validated_exposed_input = $input;
      }
    }
  }
}