1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-11 17:14:42 +02:00

typeahead support for $frm->text();

This commit is contained in:
Cameron
2013-01-31 19:11:41 -08:00
parent a33c5c70ae
commit 3002cee260
2 changed files with 40 additions and 2 deletions

View File

@@ -205,7 +205,17 @@ class e_form
$options['class'] = 'tbox input-text'; $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); $options = $this->format_options('text', $name, $options);
//never allow id in format name-value for text fields //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)." />"; 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"; if($optval) $ret .= " $optval";
break; break;
} }
if(substr($option,0,5) =='data-')
{
$ret .= " ".$option." = '{$optval}'";
}
} }
return $ret; return $ret;
@@ -1417,7 +1433,7 @@ class e_form
foreach (array_keys($user_options) as $key) 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 $user_options['name'] = $name; //required for some of the automated tasks

View File

@@ -21,6 +21,28 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
global $user; global $user;
$user['user_id'] = USERID; $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_CORE."shortcodes/batch/user_shortcodes.php");
require_once(e_HANDLER."form_handler.php"); require_once(e_HANDLER."form_handler.php");