See http://drupal.org/node/42552 for reference.
I have done everything (I think) but I still get a 403.
My new module is called "newmodule.module".
I have put the following in "newmodule.module":
/**
* Retrieve a pipe delimited string of autocomplete suggestions for existing plannames
*/
function newmodule_autocomplete($string) {
$matches = array();
$result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
while ($user = db_fetch_object($result)) {
$matches[$user->name] = check_plain($user->name);
}
print drupal_to_js($matches);
exit();
}
and, in the newmodule_menu function:
$items[] = array('path' => 'newmodule/autocomplete', 'title' => t('newmodule autocomplete'),
'callback' => 'newmodule_autocomplete', 'access' => $view_access, 'type' => MENU_CALLBACK);
Finally, I have put, in the $form['fieldset1']['field'] array:
'#autocomplete_path' => 'newmodule/autocomplete',
I get a 403 with: http://...../newmodule/autocomplete not found.
If I put that address in the address bar, indeed, it doesn't work.
However, the example in Tutorial 1 works fine (using the pre-existing user_autocomplete) in newmodule. That is, if I use:
'#autocomplete_path' => 'user/autocomplete',
My textfield autocompletes (with user names, of course) just fine.