You are here

function search_autocomplete_element_info_alter in Search Autocomplete 8

Same name and namespace in other branches
  1. 2.x search_autocomplete.module \search_autocomplete_element_info_alter()

Implements hook_element_info_alter().

The purpose of this is to include our own settings in formAPI for autocompletion configurations.

File

./search_autocomplete.module, line 23
Provides autocompletion in any field from GUI.

Code

function search_autocomplete_element_info_alter(&$types) {

  /*
   * Iterate throught the elements to find autocompletion enabled ones.
   * This methods let's all autocompletion enabled elements to be overriden,
   * even if coming from other modules or if unknown yet.
   */
  foreach ($types as $type => $info) {
    $process_methods = isset($info['#process']) ? $info['#process'] : [];
    foreach ($process_methods as $method) {

      // If the element is autocompleted, overrides it.
      if (in_array('processAutocomplete', (array) $method)) {
        $types[$type]['#process'][] = 'process_search_autocomplete';
        break;
      }
    }
  }
  return $types;
}