You are here

function search_api_autocomplete_views_config_form in Search API Autocomplete 7

Form callback for a Views-specific autocomplete configuration form.

Parameters

SearchApiAutocompleteSearch $search: The search being configured.

See also

example_autocomplete_config_form()

search_api_autocomplete_views_config_form_submit()

1 string reference to 'search_api_autocomplete_views_config_form'
search_api_autocomplete_search_api_autocomplete_types in ./search_api_autocomplete.module
Implements hook_search_api_autocomplete_types().

File

./search_api_autocomplete.search_api_views.inc, line 124
Contains code for integrating with the "Search views" module.

Code

function search_api_autocomplete_views_config_form(array $form, array &$form_state, SearchApiAutocompleteSearch $search) {
  $views_id = substr($search->machine_name, 17);
  $view = views_get_view($views_id);
  $options = array();
  foreach ($view->display as $id => $display) {
    $options[$id] = $display->display_title;
  }
  $form['display'] = array(
    '#type' => 'select',
    '#title' => t('Views display'),
    '#description' => t('Please select the Views display whose settings should be used for autocomplete queries.<br />' . "<strong>Note:</strong> Autocompletion doesn't work well with contextual filters. Please see the <a href='@readme_url'>README.txt</a> file for details.", array(
      '@readme_url' => url(drupal_get_path('module', 'search_api_autocomplete') . '/README.txt'),
    )),
    '#options' => $options,
    '#default_value' => isset($search->options['custom']['display']) ? $search->options['custom']['display'] : 'default',
  );
  return $form;
}