#autocomplete
Niels Hackius - July 10, 2007 - 19:40
| Project: | AHAH Forms Framework |
| Version: | 5.x-1.5-5 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hello,
I have the following problem with AHAH:
Is it possible that this module doesn't work with the #autocomplete_path -option from Forms API?
How do I make it work together? Any pointer would be helpful - it is just a little thing after all.
Greetings.

#1
I found a pretty bad solution:
upon creating your subform, add this to each element
'#attributes' => array('onClick' => "Drupal.autocompleteAutoAttach();")however: you don't get all the beauty of it, for example once you press Enter the thing gets submitted.
#2
My solution:
<?php$element['new_item']['text'] = array (
'#type' => 'textfield',
'#title' => t( 'Text' ),
'#autocomplete_path' => 'taxonomy/autocomplete/9',
'#size' => 40,
'#maxlength' => 128,
);
?>
Works fine!
#3
My solution:
<?php$element['new_item']['text'] = array (
'#type' => 'textfield',
'#title' => t( 'Text' ),
'#autocomplete_path' => 'taxonomy/autocomplete/1', // Where 1 is the No of your taxonomy
'#size' => 40,
'#maxlength' => 128,
);
?>
Works fine!
#4
so you are saying you didn't need a hack, but I need one? strange...
#5
okay, uhm - I just downloaded a fresh copy of drupal, and a fresh copy of aha and this doesn't work. I tried to insert this line:
'#autocomplete_path' => 'users/autocomplete',as I tried before and as you mentioned. However upon pressing the cursor-button "down" and then pressing "Enter" The form gets submitted.So if your Username is "Bob" and you insert "B" the dropdown is present to you - and even though you selected Bob from the List and hit enter - only a "B" will be submitted.
Moreover after the form is submited the newly created input field for the todo-list doesn't provide the autocomplete-capabilities anymore.
#6
I had the same problems as you have Niels. I added
'#attributes' => array('onClick' => "Drupal.autocompleteAutoAttach();")to all my fields where i need autocomplete. It fixes the problem with the autocomplete that does not work after the form is submittet.But i stil have the problem with "enter" in the autocomplete field. I was thinking about some javascript to fix the problem, but have not looked into it yet.
#7
The only solution for this, seems to be by including the function
Drupal.autocompleteAutoAttach();at the functionAhah.attach_all_bindings.Now, ideally Ahah should provide a javascript hook, so we could dynamically include more javascript that should be run "after" Ahah submitted and fetched new data from the server.
#8