Posted by Thox on May 9, 2005 at 10:11pm
Jump to:
| Project: | Drupal core |
| Version: | 4.6.0 |
| Component: | base system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
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:
<?php
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);
}
?>| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| ajax.zip | 3.97 KB | Ignored: Check issue status. | None | None |
Comments
#1
Closed.
form_autocomplete()is now committed to core (see http://drupal.org/node/22519).