Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Fields that make use of 'user/autocomplete' as their #autocomplete_path no longer work in 7.39.
This bug in contrib might offer some clues: https://www.drupal.org/node/2556749
In firebug I am seeing "TypeError: $input[0] is undefined" when the page containing my form first loads.
I'm seeing this in a custom module whose autocomplete fields worked fine for a year or so prior to the 7.39 release. Here is an example of a form field that no longer works...
$form['student'] = array(
'#title' => t('Student'),
'#type' => 'textfield',
'#size' => '20',
'#autocomplete_path' => 'user/autocomplete',
'#attributes' => array('id' => 'tutoring-student', 'placeholder' => t('Username')),
'#required' => TRUE,
'#default_value' => isset($tutoring->student) ? $tutoring->student : NULL,
'#weight' => -8,
);
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedThis issue is a duplicate of #2556749: Autocomplete not working in contrib, which is evidently, not "fixed".
Comment #3
hutch CreditAttribution: hutch commentedIn the example code above, try changing the "id" for a "class" in the '#attributes' array. You may need to change code elsewhere to accommodate. As far as I can tell Drupal-7.39 no longer tolerates more than 1 id on a form element and the automatically generated id is the one it cannot find, eg probably something like "edit-student"
Comment #4
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedTry setting the ID using the '#id' property instead of (or maybe in addition to) the above. That's the correct way to specify a specific ID in the form API. See:
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
#2554857: Add item autocomplete not working after update to Drupal 7.39
Comment #5
arnoldbird CreditAttribution: arnoldbird commentedThanks @hutch and @David_Rothstein -- changing the ID to a class, so Drupal can use the default ID, fixed this for me. I'm not sure why I set an ID in the first place. Somehow prior to 7.39 it didn't matter.