1

I want to use a textbox with autocomplete features. I have gone through the drupal form API and found the solution at here.

It's working fine if I am using this directoly in the form fields. But it's not working if I am using this any Field collections item in profile2 fields.

I am using profile2 fields with fieldscollection and following is my code.

/*profile_2_type is id for profile 2 module and it's not working for me*/    
$form['profile_2_type']['field_test_auto_cmplete']['#autocomplete_path'] = 'user/autocomplete';

/*Here is the code which is working for me for node fields */
$form['title']['#autocomplete_path'] = 'user/autocomplete';
2
  • 1
    Read through this, your issue is almost certainly related
    – Clive
    May 26, 2016 at 9:31
  • finally got the solution here is updated code $form['profile_2_type']['field_test_auto_cmplete']['und'][0]['value']['#autocomplete_path'] = 'user/autocomplete'; and "user/autocomplete" only works for admin users May 26, 2016 at 11:37

1 Answer 1

2

finally got the solution here is updated code

$form['profile_2_type']['field_test_auto_cmplete']['und'][0]['value']['#autocomplete_path'] = 'user/autocomplete';

and "user/autocomplete" only works for admin users

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.