I am creating my own form in my module using the Form API.
How do I enter multiple values in the below textfield and have it autocompleted, and suggested (separated by commas, for example)?
Right now it takes whatever is in the textfield box as one single big string.
$form['keywords'] = array(
'#type' => 'textfield',
'#title' => t('Keywords'),
'#size' => '40',
'#multiple' => TRUE,
'#autocomplete_path' => 'papers_pub_search/keywords_autocomplete'
);
function _autosearch($string) {
$query = "SELECT name FROM users WHERE name LIKE :name";
$result = db_query($query, array(':name'=> '%' . db_like($string) . '%'));
foreach($result as $row) {
$match[$row->name] = check_plain($row->name);
}
drupal_json_output($match);
}