Autocomplete on "Unlimited" text field? I'm adding Drupal's built in Autocomplete functionality using hook_form_alter to set the #autocomplete_path like so:

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  ...
  $form['field_company']['und'][0]['value']['#autocomplete_path'] = 'autocomplete/company';
  ...
}


This works perfectly for a text field where the number of values is 1, but doesn't work when the number of values is unlimited. I'm assuming this has something to do with the field be added via Javascript. Is there another hook I can tap in to in order to add the #autocomplete_path?

EDIT : Drupal 6.
You have to iterate your field's delta ; here, you only affect $form['field_company']['und']__[0]__, not  $form['field_company']['und']__[n]__

Stay in your hook_form_alter but iterate it each time your $form is rebuild :

    foreach($form['field_company']['und'] as $delta =&gt; $field) {
        if(is_array($field) &amp;&amp; is_numeric($delta)) {
            $form['field_company']['und'][$delta]['value']['#autocomplete_path'] = 'autocomplete/company';
        }
    }