Note: This module is no longer supported. Its functionality is now included in Drupal 6.

Ahah forms is a utility module, for adding Ajax/javascript driven incremental page reloading, without needing to write any Javascript.

This framework uses the FormAPI to generate the necessary Javascript. The key is the #ahah_binding property. There are two places to use this property.

#1) Attached to an existing form element. ex:

	$subform['new_choice']['add_choice_button'] = array (
	    '#type' => 'button',
	    '#value' => t( 'Add New Choice' ),
	    '#id' => 'poll_add_choice_button', 
	    '#ahah_bindings' => array ( 
		    	'wrapper' => 'poll_choices_wrapper',
	 			'event' => 'click',
	  			'path' => 'poll/poll_update_js',

#2) Attached to a wrapper, to bind to a dynamic set of elements, which do not exist when the page is first rendered. ex:

	// establish the choices wrapper
  	$form['choices'] = array (
  		'#type' => 'fieldset',
  		'#title' => 'Choices',
	    '#prefix' => '
', '#suffix' => '
', '#ahah_bindings' => array( array ( 'selector' => 'input.poll_choice_remove', 'event' => 'click', 'wrapper' => 'poll_choices_wrapper', 'path' => 'poll/poll_update_js', ), array ( 'selector' => 'select.poll_choice_weight', 'event' => 'change', 'wrapper' => 'poll_choices_wrapper', 'path' => 'poll/poll_update_js', ), ), );

In both cases most of the sub-parameters are the same:
'event' - javascript event - click and change are the only two currently supported
'wrapper' - the area that will be replaced when the event occurs. It is currently assumed that the element is inside this wrapper.
'path' - the Drupal system path to call to get the updated html to put into the wrapper
'class' (optional) - the class of form elements to bind to. If this is missing, the element's id is used.
'params' (optional) - an array of parameters to pass back to the path.

* Currently only works with Clean URL's enabled

This project is supported by CITRIS: The Center for Information Technology Research in the Interest of Society, located at UC Berkeley

Project Information