<div dir="ltr"><div><div><div><div><div>In D7, I have added a field to the article content type. A taxonomy reference with autocomplete. I need to customize the autocomplete behavior.<br><br></div>I tried the following:<br>
</div>1. hook_form_alter to change the autocomplete path<br></div>2. hook_menu to register the path as a callback<br></div><div>3. create the callback function and have it do a simple print<br></div><br></div><div>Prior to doing this, typing in the field would fire autocomplete as expected. And I also see the communication in the console of firebug. Having made the two changes, I see the new path in the correct place in the form field, but nothing happens when I type in the field other than the characters appearing...the logic isn&#39;t fired and firebug shows no communication. <br>
<br></div><div>I also tried registering the original autocomplete path with a different callback. Same result.<br></div><div><br>Below are the functions.<br><br>/**<br> * Implements hook_menu().<br> */<br>function my_article_menu() {<br>
  $items[&#39;a/categories&#39;] = array(<br>    &#39;page callback&#39; =&gt; &#39;my_article_autocomplete_callback&#39;,<br>    &#39;page arguments&#39; =&gt; array(1),<br>    &#39;type&#39; =&gt; MENU_CALLBACK,<br>  );<br>
<br>  return $items;<br>}<br>/**<br> * Implements hook_form_alter().<br> */<br>function my_article_form_alter(&amp;$form, $form_state, $form_id) {<br>  if ($form_id == &#39;article_node_form&#39;) {<br>    $form[&#39;field_a_categories&#39;][&#39;und&#39;][&#39;#autocomplete_path&#39;] = &#39;a/categories&#39;;<br>
  }<br>}<br><br></div><div><div><div><div><div><div><div>function my_article_autocomplete_callback($vocabulary_name) {<br>  print &#39;***** The vocabulary is &#39; . $vocabulary_name;<br>}<br><br>-- <br>---<div><a href="http://drupal.org/user/367108" target="_blank">drupal.org/user/367108</a></div>
<div><a href="http://linkedin.com/in/jeffrgreenberg" target="_blank">linkedin.com/in/jeffrgreenberg</a></div><div><a href="http://accidentalcoder.com" target="_blank">accidentalcoder.com</a> / <a href="http://ayendesigns.com" target="_blank">ayendesigns.com</a></div>
<div>@accidentalcoder</div>
</div></div></div></div></div></div></div></div>