I just upgraded from Drupal 6.4 to Drupal 6.6. I have a custom autocomplete feature on my main search form (search_block_form). After I upgraded, the form stopped autocompleting, even when I'm User 1. I assume it has to do with the fact that autocomplete is turned off in D6.6 when the user does not have the right permissions. But I can't figure out why I don't have the necessary permissions.

Here's the relevant menu item:

  // Return autocomplete matches for search
  $items['foo/autocomplete/%menu_tail'] = array(
    'access callback' => 'user_access',
    'access arguments' => array('search content'),
    'page callback' => 'foo_autocomplete',
    'page arguments' => array(2),
    'type' => MENU_CALLBACK,
  );

(I've also tried 'access callback' => TRUE and 'access arguments' => array('access content').)

Any thoughts?

Comments

dave reid’s picture

Have you just tried loading the autocomplete URL to make sure it is returning valid data?

grobemo’s picture

Yep. Going directly to the autocomplete URL returns exactly what it should (in JSON format). I've tested it as an anonymous user and as user 1.

grobemo’s picture

Component: forms system » menu system
Status: Active » Closed (duplicate)

It turns out the problem with the Teleport module's autocomplete in D6.6 was the same, as was the solution: eliminate %menu_tail from the key in $items.

In other words, my code now looks like this:

  $items['foo/autocomplete'] = array(
    'access callback' => 'user_access',
    'access arguments' => array('search content'),
    'page callback' => 'foo_autocomplete',
    'page arguments' => array(2),
    'type' => MENU_CALLBACK,
  );

The only change is that I deleted '/%menu_tail'. After clearing the cache to reset the menu, autocomplete is back.

I have no idea why this works, because I've never fully understood %menu_tail. But it works.

veeraprasadd’s picture