Closed (duplicate)
Project:
Drupal core
Version:
4.6.0
Component:
base system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 May 2005 at 22:11 UTC
Updated:
24 May 2005 at 13:24 UTC
I'd like some AJAX code built-in to the Drupal core. I've done this and gone one step further by creating an AJAX module that has a functional form_autocomplete() field type - that can be used on any form field.
The function has one extra parameter- $callback. This is a Drupal path to a callback function which will return the autocomplete results for the field to display. The results are returned as a pipe (|) delimitted list of strings.
Here's an example callback function I'm already using:
function recipe_autocomplete_page($string, $limit = 10) {
$matches = array();
$rs = db_query('SELECT name FROM {recipe_ingredient} WHERE name LIKE "%%%s%%" LIMIT %d', $string, $limit);
while ($r = db_fetch_object($rs)) {
$matches[] = $r->name;
}
echo implode('|', $matches);
}
Comments
Comment #1
Thox commentedClosed.
form_autocomplete()is now committed to core (see http://drupal.org/node/22519).