Download & Extend

Ajax autocomplete field (ajax module)

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);
}
?>
AttachmentSizeStatusTest resultOperations
ajax.zip3.97 KBIgnored: Check issue status.NoneNone

Comments

#1

Title:AJAX form_autocomplete() field» Ajax autocomplete field (ajax module)

Closed.

form_autocomplete() is now committed to core (see http://drupal.org/node/22519).

nobody click here