[support] Drupal 6.10 autocomplete ignored in hook_user() register?

Doug doug.duboulay at gmail.com
Wed May 19 02:29:35 UTC 2010


This is a bit obscure but...

I'm trying to alter the new user registration form in my
modules hook_user() function in order to get users to 
select a unique short identifier (e.g. initials).

Although I add the '#autocomplete_path' => 'module/autocomplete/charid'
to the form textfield element, it is not activated.

In fact the "form-autocomplete" class attribute is never added to the element,
there is no matching hidden "autocomplete" input class element and 
misc/autocomplete.js is never loaded by the page. 

It works when I add it to the hook_user() edit option (but of course I
don't want users to be able to edit it then).

Apparently I can work around it, but I'm not sure why I have to.

 drupal_add_js('misc/autocomplete.js');

  $form['user']['uCharID'] = array(
    '#required' => TRUE,
    '#type' => 'textfield',
    '#title' => t('User ID - 3 chars'),
     '#size' => 4,
     '#maxlength' => 4,
     '#attributes' => array('class' => 'form-autocomplete'),
     '#autocomplete_path' => 'mymodule/autocomplete/charid', //ignored
     '#description' => t('Your unique 3 character user identifier'),
     '#suffix' => '<input class="autocomplete" type="hidden"'
       . ' id="edit-uCharID-autocomplete" 
       . ' value="/?q=mymodule/autocomplete/charid"/>',
      );





More information about the support mailing list