I'm just reporting this so that other people will be aware of the problem if they go looking for it. Hopefully this saves someone some time. My apologies if this has been reported elsewhere, I could not find any similar reports.

I have two hierarchical select forms on one page that were both sharing the same form builder function. No matter what, only the first form would hit the submit handler with the proper values. I started by using the implied submit handler as you normally can with the FAPI and that worked fine for the first form, but when clicking the submit button for the second form, the $form_state['values'] array comes in with the first form's form element key set, but it's empty. So, clicking form A's submit button would work fine, but clicking form B's submit button would give me form A with empty values. The $form_state['clicked_button']['#post'] values seem to always be correct, but only the deepest term is there, not the whole tree. This problem wouldn't go away even when explicitly setting the submit handler to unique functions, one for each form. The first submit function would always be used and the second would always be ignored.

The workaround I found was to not use a form builder that shared the same function name for both forms by passing in arguments. Instead I now have to use something like: $output = drupal_get_form('my_hs_form_1'); and $output = drupal_get_form('my_hs_form_2'); which works as expected.

Comments

Gold’s picture

Status: Active » Closed (won't fix)

Tidying up the issue queue. The 6.x version is no longer supported. Only reopen this if it also applies to the 7.x.