aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/autocomplete.php
blob: 8fe5ab664e0fbb42098ca6d030048815f82e10c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * Displays an autocomplete text input.
 *
 * @package Elgg
 * @subpackage Core
 *
 * @todo This currently only works for ONE AUTOCOMPLETE TEXT FIELD on a page.
 *
 * @uses $vars['match_on'] Array | str What to match on. all|array(groups|users|friends|subtype)
 * @uses $vars['match_owner'] Bool.  Match only entities that are owned by logged in user.
 *
 */

$defaults = array(
	'class' => '',
	'value' => '',
);

$vars = array_merge($defaults, $vars);

$vars['class'] = trim("elgg-input-autocomplete {$vars['class']}");

$ac_url_params = http_build_query(array(
	'match_on' => $vars['match_on'],
	'match_owner' => $vars['match_owner'],
));

elgg_register_js('js/lib/autocomplete.js', 'autocomplete', 'footer');

?>

<script type="text/javascript">
elgg.autocomplete.url = "<?php elgg_get_site_url() . 'pg/livesearch?' . $ac_url_params; ?>";
</script> 
<input type="text" <?php echo elgg_format_attributes($vars); ?> />