// Show User Picker... (ADMINS ONLY)
$_tmp = array(
'name' => 'profile_user_id', // this is the name of the field in the datastore
'group' => 'admin', // only admin users will see this field in the form
'label' => 'profile owner', // the text label for the field in the form
'help' => 'What User Account should this profile be created for? The User Account selected here will have admin capabilities for the Profile.', // the help text which appears when clicking the ? button
'type' => 'live_search', // this is what makes the field in the form display the live search.
'target' => "{$_conf['jrCore_base_url']}/{$_post['module_url']}/get_profile_users", // the url to query
'value' => $_user['_user_id'], // sends the user_id so you do not see yourself in the search results
'required' => false, // is it required or not
'validate' => 'number_nz', // check that it is a number greater than zero, return an error if it is not
'form_designer' => false // We do not allow the form designer to override this field
);
jrCore_form_field_create($_tmp);
function view_jrProfile_get_profile_users($_post,$_user,$_conf)
{
jrUser_admin_only();
$tbl = jrCore_db_table_name('jrUser','item_key');
$req = "SELECT `_item_id`, `value` FROM {$tbl} WHERE `key` = 'user_name' AND `value` LIKE '". jrCore_db_escape($_post['q']) ."%' ORDER BY `value` ASC";
$_sel = jrCore_db_query($req,'_item_id',false,'value');
return jrCore_live_search_results('profile_user_id',$_sel);
}
<input type="text" id="profile_user_id" class="form_text live_search_text" name="profile_user_id" value="search" tabindex="2" onfocus="if($(this).val() == 'search'){ $(this).val('').removeClass('live_search_text'); }">
<script type="text/javascript">
$(document).ready(function(){
try { $('#profile_user_id').liveSearch( { url:'{$_conf['jrCore_base_url']}/{$murl}/get_profile_users/q='}); } catch(e) { };
return true;
});
</script>