In the example module subform_example_subform2_validate() is called only from the first subform, it doesn't work when called from the 2nd subform.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

FileSize
9.4 KB
25.56 KB

Digging a bit more I see where it falls:

On the first form, we have all the required values in $form_state['input'], so in form_builder()

    if ($form_state['programmed'] || (!empty($form_state['input']) && (isset($form_state['input']['form_id']) && ($form_state['input']['form_id'] == $form_id)))) {
      $form_state['process_input'] = TRUE;
    }

is executed.

However clicking on validate/ submit on the second subform doesn't populate $form_state['input'] properly (see images).

amitaibu’s picture

FileSize
111.1 KB

And now I see why the $_POST values are different. The 2nd subform has <form> tag, while the 1st one doesn't. (see image)

amitaibu’s picture

Status: Active » Needs review
FileSize
511 bytes

Ha, I think I got it ;) -- change the subform's #theme_wrapper to container instead of form.

amitaibu’s picture

Better patch, it seems that this was supposed to work already, however in after_build we add #pre_render to $form instead of $element, resulting in never calling the pre-render function.

casey’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.