File tree 1 file changed +32
-0
lines changed
modules/elasticsearch_connector_search_api
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,38 @@ function elasticsearch_connector_search_api_module_implements_alter(&$implementa
266
266
if ($hook == 'form_views_exposed_form_alter') {
267
267
unset($implementations['search_api_autocomplete']);
268
268
}
269
+ elseif ($hook == 'form_search_api_page_search_form') {
270
+ unset($implementations['search_api_autocomplete']);
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Implements hook_form_FORM_ID_alter().
276
+ *
277
+ * Adds autocompletion to the keywords field on search pages, if enabled by the
278
+ * user.
279
+ */
280
+ function elasticsearch_connector_search_api_form_search_api_page_search_form_alter(array &$form, array &$form_state) {
281
+ if (isset($form['form'])) {
282
+ $form = &$form['form'];
283
+ }
284
+ $id = 'search_api_page_' . $form['id']['#value'];
285
+ $search = search_api_autocomplete_search_load($id);
286
+ if ($search && $search->enabled) {
287
+ $include_js = FALSE;
288
+ $search->alterElement($form['keys_' . $form['id']['#value']]);
289
+ if (!empty($search->options['custom']['link_suggestions'])) {
290
+ $form['keys_' . $form['id']['#value']]['#attributes'] = array(
291
+ 'class' => array('elasticsearch-autocomplete')
292
+ );
293
+ $include_js = TRUE;
294
+ }
295
+
296
+ if ($include_js) {
297
+ $form['#attached']['js'][] =
298
+ drupal_get_path('module', 'elasticsearch_connector_search_api') . '/js/elasticsearch_connector_search_api_autocomplete.js';
299
+ }
300
+ }
269
301
}
270
302
271
303
/**
You can’t perform that action at this time.
0 commit comments