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.

Comments

nhck’s picture

Category: feature » support
Priority: Minor » Normal

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.

macm’s picture

My solution:

	$element['new_item']['text'] = array (
	    '#type' => 'textfield',
	    '#title' => t( 'Text' ),
	    '#autocomplete_path' => 'taxonomy/autocomplete/9', 
	    '#size' => 40,
	    '#maxlength' => 128,
	);

Works fine!

macm’s picture

My solution:

	$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!

nhck’s picture

so you are saying you didn't need a hack, but I need one? strange...

nhck’s picture

Category: support » bug

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.

beltofte’s picture

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.

fall_0ut’s picture

The only solution for this, seems to be by including the function Drupal.autocompleteAutoAttach(); at the function Ahah.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.

nhck’s picture

Status: Active » Closed (fixed)