Just a couple of minor issues.

After fixing the typo on line 145 of ahah_helper.module:

  if (isset($form_state['storage']['#ahah_helper']['file'])) {
    require_once($form_state['storage']['#ahah_helper']['#file']); // remove hash from #file
  }

..I discovered this problem:

If a form definition is stored in a different file, the ahah_helper seems to cause the form builder to be called twice. This results in all form ids having "1" appended to them (since drupal 6 form builder is set up to prevent duplicate element ids).

function test_menu() {
  $items['test/edit'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => 'test_form',
    'file' => 'test.form.inc', // this causes the problem when ahah is employed in test_form
  );
}

It was also causing me problems when I tried to build markup items differently based on the existence of $form_state['storage'] variables.

It's an awesome module though. Thanks!

Comments

Rok Žlender’s picture

This is not a simple problem. Because ahah_helper sets $form_state['storage'] form is built twice on every load. First time in normal form generation in line 95 of form.inc and second time in line 142 where it checks for storage which is not empty in our case. So now our form went through generation twice and b/c Drupal keeps track of every id it assigns to form elements on second run all ids get -1 http://api.drupal.org/api/function/form_clean_id/6 .

I wouldn't think many people would find this to be a problem. After submitting such forms keys in $form_state variable in submit function are fine. Problem in my case is that we want to use js to change some form values and then submit with ahah. But because all form elements get new id our js doesn't find them.

Few solutions:

  1. Don't use include files for your ahah forms
  2. In our case we can fix our js to search for -1 form element ids
  3. Don't use ahah helper :(

I'll probably go with 2.

Rok Žlender’s picture

New Drupal core version 6.14 introduces some changes to form generation which solves this ticket. heathergaye can you confirm that it solves your problem.

Rok Žlender’s picture

Status: Active » Closed (cannot reproduce)