You are here

function apachesolr_autocomplete_do_alter in Apache Solr Autocomplete 6

Same name and namespace in other branches
  1. 7.2 apachesolr_autocomplete.module \apachesolr_autocomplete_do_alter()
  2. 7 apachesolr_autocomplete.module \apachesolr_autocomplete_do_alter()

Helper function to do the actual altering of search forms.

Parameters

$element: The element to alter. Should be passed by reference so that original form element will be altered. E.g.: apachesolr_autocomplete_do_alter(&$form['xyz'])

3 calls to apachesolr_autocomplete_do_alter()
apachesolr_autocomplete_form_search_block_form_alter in ./apachesolr_autocomplete.module
Implementation of hook_form_FORM_ID_alter().
apachesolr_autocomplete_form_search_form_alter in ./apachesolr_autocomplete.module
Implementation of hook_form_FORM_ID_alter().
apachesolr_autocomplete_form_search_theme_form_alter in ./apachesolr_autocomplete.module
Implementation of hook_form_FORM_ID_alter().

File

./apachesolr_autocomplete.module, line 60
Alters search forms to suggest terms using Apache Solr using AJAX. Thanks to robertDouglass who contributed some of the code.

Code

function apachesolr_autocomplete_do_alter(&$element) {
  if (apachesolr_autocomplete_variable_get_widget() == 'custom') {

    // Create elements if they do not exist.
    if (!isset($element['#attributes'])) {
      $element['#attributes'] = array();
    }
    if (!isset($element['#attributes']['class'])) {
      $element['#attributes']['class'] = 'apachesolr-autocomplete unprocessed';
    }
    else {
      $element['#attributes']['class'] .= ' apachesolr-autocomplete unprocessed';
    }
  }
  else {
    $element['#autocomplete_path'] = 'apachesolr_autocomplete';
  }
}