autocomplete on a multi value - custom field I have a field organizations on the user profile(the field can accept multiple values). I would like to add a autocomplete to this field. My code for this is 

&lt;?php
/**
 * Implementation of hook_menu()
 */
function org_ac_menu() {
  $items = array();
  $items['org_ac/autocomplete'] = array(
    'page callback' =&gt; 'org_ac_autocomplete',
    'access callback' =&gt; TRUE,
    'access arguments' =&gt; array('access dbpedia autocomplete'),
    'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implementation of hook_form_alter()
 */
function org_ac_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    //$form['field_organization']['#autocomplete_path'] = 'org_ac/autocomplete';
    $form['field_organization']['und'][0]['value']['#autocomplete_path'] = 'org_ac/autocomplete'; **/* This works but only on the first input field! */**
  }
}

/**
 * Check for possibilities in dbpedia
 */
function org_ac_autocomplete($string = '') {
  $found = array();

  $url = 'http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?QueryString='.urlencode($string).'&amp;MaxHits=5';
  $result = file_get_contents($url);
  $data = simplexml_load_string($result);

  foreach($data-&gt;Result as $res_temp)
  {
      $found[check_plain($res_temp-&gt;Label)] = check_plain($res_temp-&gt;Label);
  }

  drupal_json_output($found);
}


The code works when I reference this element on the form, -> 

$form['field_organization']['und'][0]['value']['#autocomplete_path'] = 'org_ac/autocomplete'; 


But since it can accept multiple values, the autocomplete doesn't work on the remaining elements ->$form['field_organization']['und'][1]  &amp;  $form['field_organization']['und'][2]['value']['value'] 

How can I make it work on all the input elements for the organization field ?

Thanks
If you modify your hook_form_alter to loop through the $delta of field_organization it should work for you on multiples...

/**
 * Implementation of hook_form_alter()
 */
function org_ac_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    foreach($form['field_organization'][LANGUAGE_NONE] as $delta =&gt; $field) {
      if(is_array($field) &amp;&amp; is_numeric($delta)) {
        $form['field_organization'][LANGUAGE_NONE][$delta]['value']['#autocomplete_path'] = 'org_ac/autocomplete';
      }
    }
  }
}