You are here

function facetapi_search_form_validate in Facet API 6

Validates search_form form submissions.

1 string reference to 'facetapi_search_form_validate'
facetapi_form_search_form_alter in ./facetapi.module
Implementation of hook_form_FORM_ID_alter().

File

./facetapi.module, line 1383
An abstracted facet API that can be used by various search backens.

Code

function facetapi_search_form_validate($form, &$form_state) {

  // Captures facet values passed through the form, appends the value to the
  // facet definition so we have all the necessary information at hand.
  $facets = array();
  foreach (facetapi_enabled_facets_get($form['module']['#value']) as $facet) {
    if (isset($form_state['values'][$facet['field alias']])) {
      $value = $form_state['values'][$facet['field alias']];
      $value = is_array($value) ? array_filter($value) : drupal_explode_tags($value);
      if (!empty($value)) {
        $facet['values'] = $value;
        $facets[] = $facet;
      }
    }
  }

  // Stores facet definitions with passed values in the container.
  form_set_value($form['basic']['inline']['processed_facets'], $facets, $form_state);
}