mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 09:04:38 +02:00
typeahead support for $frm->text();
This commit is contained in:
@@ -205,7 +205,17 @@ class e_form
|
||||
$options['class'] = 'tbox input-text';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(vartrue($options['typeahead']))
|
||||
{
|
||||
$options['data-provide'] ="typeahead";
|
||||
if(vartrue($options['typeahead']) == 'users')
|
||||
{
|
||||
$options['data-source'] = e_BASE."user.php";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$options = $this->format_options('text', $name, $options);
|
||||
//never allow id in format name-value for text fields
|
||||
return "<input type='text' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />";
|
||||
@@ -1363,6 +1373,12 @@ class e_form
|
||||
if($optval) $ret .= " $optval";
|
||||
break;
|
||||
}
|
||||
|
||||
if(substr($option,0,5) =='data-')
|
||||
{
|
||||
$ret .= " ".$option." = '{$optval}'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -1417,7 +1433,7 @@ class e_form
|
||||
|
||||
foreach (array_keys($user_options) as $key)
|
||||
{
|
||||
if(!isset($def_options[$key])) unset($user_options[$key]);//remove it?
|
||||
if(!isset($def_options[$key]) && substr($key,0,5)!='data-') unset($user_options[$key]); // data-xxxx exempt //remove it?
|
||||
}
|
||||
|
||||
$user_options['name'] = $name; //required for some of the automated tasks
|
||||
|
22
user.php
22
user.php
@@ -21,6 +21,28 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
||||
global $user;
|
||||
$user['user_id'] = USERID;
|
||||
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
if(vartrue($_GET['q']))
|
||||
{
|
||||
$q = filter_var($_GET['q'], FILTER_SANITIZE_STRING);
|
||||
if($sql->select("user", "user_name", "user_name LIKE '". $q."%' ORDER BY user_name LIMIT 15"))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$data[] = $row['user_name'];
|
||||
}
|
||||
|
||||
if(count($data))
|
||||
{
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// require_once(e_CORE."shortcodes/batch/user_shortcodes.php");
|
||||
require_once(e_HANDLER."form_handler.php");
|
||||
|
||||
|
Reference in New Issue
Block a user