Hello

I'm using contact_forms in a project, where I need the to make som dynamic changes to the contact form via AHAH.
I have my own module to do that, but contact_forms is causing major problems.

Because this module asumes that the path used to render the form is 'contact' I can not make any AHAH calls (which are definitely not in the 'contact' path) it causes a redirect.

I'm attaching 2 patches, one for the 1.12 and one for the 1.x-dev

What is the logic behind it:

We want to alter the form only when there is a second parameter [arg(1)] which corresponds to the category of the message.
Once we are in, we save the category in $form_state['storage']['contactform_redirect'] so subsequent calls know we have a category, regardless of the path used to make the call
For every other call (those made via AHAH) we do not check the path but we check whether we have a category set in $form_state['storage']

So basically we alter the form if it is beng called from /contact/* or if we have $form_state['storage']['contactform_redirect'].

I haven't tested the patch for the dev version, but the one for 1.12 works.

I urge you to commit this, since AHAH is being used more and more everyday and believe me, it spent hours trying to find the problem.

Cheers

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jm.federico’s picture

jm.federico’s picture

Title: bad implementation of path [arg()] check causes redirect » bad implementation of path [arg()] check causes 302 redirect
jm.federico’s picture

Title: bad implementation of path [arg()] check causes 302 redirect » hook_form_alter causes 302 redirect - Big issue for AHAH calls!

I just read the title and realized it makes no sense!
Changing!

behindthepage’s picture

Hi,

I haven't had time to look at this closely but have a few questions.

1. Will your patch allow any one to add an AHAH solutions with my module or is it just for your AHAH?

2. Does it change any of the functionality of my module?

Regards
Geoff

jm.federico’s picture

Hello

It changes no functionality (according to my tests) and it is generic enough so that any AHAH call should work.

Plz note that I haven't tested the dev version. Patch for dev was made solely from my experience with 1.12, but should work.

Cheers

Summit’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Hi, How will this work on D7 version please?
greetings, Martijn

behindthepage’s picture

Status: Needs review » Closed (won't fix)