Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
autocomplete.php
Go to the documentation of this file.
1 <?php
16 if (isset($vars['class'])) {
17  $vars['class'] = "elgg-input-autocomplete {$vars['class']}";
18 } else {
19  $vars['class'] = "elgg-input-autocomplete";
20 }
21 
22 $defaults = array(
23  'value' => '',
24  'disabled' => false,
25 );
26 
27 $vars = array_merge($defaults, $vars);
28 
29 $params = array();
30 if (isset($vars['match_on'])) {
31  $params['match_on'] = $vars['match_on'];
32  unset($vars['match_on']);
33 }
34 if (isset($vars['match_owner'])) {
35  $params['match_owner'] = $vars['match_owner'];
36  unset($vars['match_owner']);
37 }
38 $vars['type'] = 'text';
39 $vars['data-source'] = elgg_get_site_url() . 'livesearch?' . http_build_query($params);
40 
41 echo elgg_format_element('input', $vars);
42 
43 // inline script in case loaded via ajax
44 ?>
45 <script>
46 require(['elgg/autocomplete'], function (autoc) {
47  autoc.init();
48 });
49 </script>
$defaults
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:218
$vars
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
$params