You are here

public function SearchApiLiveResultsSearch::alterElement in Search API live results 7

Helper method for altering a textfield form element to use live results.

File

./search_api_live_results.module, line 393

Class

SearchApiLiveResultsSearch
Class describing the settings for a certain search for which autocompletion is available.

Code

public function alterElement(array &$element) {
  if (user_access('use_search_api_live_results')) {
    $element['#type'] = 'live_results_search';
    if (isset($this->options['caching']) && $this->options['caching']) {
      $element['#autocomplete_path'] = drupal_get_path('module', 'search_api_live_results') . '/search_api_live_results.results.php';
      $element['#autocomplete_query'] = array(
        'search' => $this->machine_name,
      );
    }
    else {
      $element['#autocomplete_path'] = 'search_api_live_results/' . $this->machine_name;
    }
  }
}