Drupal6 AHAh Examples

In my search for information about making dynamic forms for Drupal 6 I found randyfay.com/content/what-ahah-drupal which was very helpful. From there I found the example modules at drupal.org/project/examples. I added the ahah_example module to this site and then proceeded to experiment.

I added the following code to ahah_example.module,
// Add another textfield
$items['examples/ahah_example/anothertextfield'] = array(
'title' => 'Add textfields',
'page callback' => 'drupal_get_form',
'page arguments' => array('ahah_example_anothertextfield'),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
'weight' => 4,
'file' => 'ahah_example_anothertextfield.inc',
);
$items['examples/ahah_example/anothertextfield/callback'] = array(
'page callback' => 'ahah_example_anothertextfield_callback',
'access callback' => TRUE,
'file' => 'ahah_example_anothertextfield.inc',
'type' => MENU_CALLBACK,
);

I also made a new file ahah_example_anothertextfield.inc which contains the code for the example form which allows adding and removing any number of textfields before final submission. This code was adapted from the code in the ahah_example module. Assistance with added AHAH to the new submit buttons was found here:
api.drupalize.me/api/drupal/function/filefield_js/6

The attached zip file contains the code I added to the module. If you want to try it out get a copy of the original ahah_example module from drupal.org/project/examples add the ahah_example_anothertextfield.inc file and replace the ahah_example.module file with the one in the zip file.