<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'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['a/categories'] = array(<br> 'page callback' => 'my_article_autocomplete_callback',<br> 'page arguments' => array(1),<br> 'type' => MENU_CALLBACK,<br> );<br>
<br> return $items;<br>}<br>/**<br> * Implements hook_form_alter().<br> */<br>function my_article_form_alter(&$form, $form_state, $form_id) {<br> if ($form_id == 'article_node_form') {<br> $form['field_a_categories']['und']['#autocomplete_path'] = 'a/categories';<br>
}<br>}<br><br></div><div><div><div><div><div><div><div>function my_article_autocomplete_callback($vocabulary_name) {<br> print '***** The vocabulary is ' . $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>