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"/>', );
Doug wrote:
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.
Do you have a MENU_CALLBACK defined for the path and a function to give the values for the auto completion?
On Wed, 19 May 2010, Earnie Boyd wrote:
Doug wrote:
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.
Do you have a MENU_CALLBACK defined for the path and a function to give the values for the auto completion?
Yes. And it works fine when called via hook_user($op='form',...), it just doesn't work when called via $op='register'.