You are here

function process_search_autocomplete in Search Autocomplete 8

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

Adds autocomplete functionality to elements.

This sets up autocomplete functionality for elements with an #autocomplete_configuration property.

Parameters

array $element: The form element to process.

Return value

array The form element.

1 string reference to 'process_search_autocomplete'
search_autocomplete_element_info_alter in ./search_autocomplete.module
Implements hook_element_info_alter().

File

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

Code

function process_search_autocomplete(&$element) {
  if (!empty($element['#autocomplete_configuration'])) {
    attach_configuration_to_element($element, $element['#autocomplete_configuration']);
    $element['#attributes']['class'][] = 'form-autocomplete';
    $element['#attached']['library'][] = 'core/drupal.autocomplete';
    $element['#attributes']['data-key'] = $element['#autocomplete_configuration'];
  }
  return $element;
}