Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1154592-fix-theme-wrapper-4.patch | 1.15 KB | amitaibu |
#3 | fix-theme-wrapper.patch | 511 bytes | amitaibu |
#2 | extra-form.jpg | 111.1 KB | amitaibu |
#1 | first-form.jpg | 25.56 KB | amitaibu |
#1 | second-form.jpg | 9.4 KB | amitaibu |
Comments
Comment #1
amitaibuDigging 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()
is executed.
However clicking on validate/ submit on the second subform doesn't populate $form_state['input'] properly (see images).
Comment #2
amitaibuAnd now I see why the $_POST values are different. The 2nd subform has
<form>
tag, while the 1st one doesn't. (see image)Comment #3
amitaibuHa, I think I got it ;) -- change the subform's #theme_wrapper to container instead of form.
Comment #4
amitaibuBetter 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.
Comment #5
casey CreditAttribution: casey commentedCommitted, thanks!