This code will create an input with autocomplete to be included in a form somewhere, then you'd need to build the code to do something with the selected option:
Form
<div class="cell">
<input id="fUser" name="user" type="text" class="fUser input-text input-actions" value="<?php echo osc_esc_html(Params::getParam('user')); ?>" />
<input id="fUserId" name="userId" type="hidden" value="<?php echo osc_esc_html(Params::getParam('userId')); ?>" />
</div>
<script type="text/javascript">
document.write('<style type="text/css"> .tabber{ display:none; } </style>');
$(document).ready(function(){
$('input[name="user"]').attr( "autocomplete", "off" );
$('#user,#fUser').autocomplete({
source: "<?php echo osc_base_url(true); ?>?page=ajax&action=runhook&hook=user_search",
minLength: 0,
select: function( event, ui ) {
if(ui.item.id=='') {
return false;
}
$('#userId').val(ui.item.id);
$('#fUserId').val(ui.item.id);
}
});
$('.ui-autocomplete').css('zIndex', 10000);
});
</script>
***********************
functions.php (Ajax for Autocomplete)
<?php
function cust_ajax_user_search() {
$users = User::newInstance()->ajax(Params::getParam("term"));
if(count($users)==0) {
echo json_encode(array(0 => array('id'=> '', 'label' => __('No results'), 'value' => __('No results')) ));
} else {
echo json_encode($users);
}
}
osc_add_hook('ajax_user_search', 'cust_ajax_user_search');
?>
Regards