By ooXei1sh on
I need to combine and return two forms into a single form. The code below combines my two forms...
/**
* Form Elements - return step1 and step2
*/
function form_fullform($form, &$form_state) {
$form = array();
$form_step1 = drupal_get_form('form_step1');
$form_step2 = drupal_get_form('form_step2');
$form = drupal_array_merge_deep($form_step1, $form_step2);
return $form;
}
...but it displays the fields are in the wrong order. Has anyone encountered this before?
Comments
This isn't going to work for
This isn't going to work for two reasons:
1) The weights are sorted before being called into drupal_get_form, and you are merging it from there, so the weights aren't likely to be obeyed.
2) You have called drupal_get_form() twice, which means that merging them won't work, since you have separate form IDs.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks
Thank you for the reply. I ended up using conditional statements within a single form builder function and it seems to be working.
I'm not sure that this is the best approach. But I really want to have one set of form elements and not have to duplicate them. If anyone else is looking at this and needs to fill in the blanks of what I left out just download the 'examples' module and checkout the form_example_wizard.