I am building on an existing site, adding / modifying functionality to it.
There is a form, which is a part of a (sort of a) multi-step form which I need to alter, and add another form to it.
So, I added the following to the existing form:
// Some form elements above this. $form['new_form_element']['search'] = drupal_get_form('MY_PROJECT_search_form'); // Some form elements after this
MY_PROJECT_search_form function returns the form, which is then embedded in the original form. The form is rendered properly.
However, when I submit the form, I get the following notice :
The form has become outdated. Copy any unsaved work in the form below and then reload this page.
I believe that is because the two forms are getting submitted at the same time, and the submission of one of them is failing.
I have tried adding
$form_state['rebuild'] = TRUE to the submit functions, but it did not work.
I have also tried adding an
markup type field and embedding form in as
'#markup' = render(drupal_get_form('MY_PROJECT_search_form'));
But, I am not able to implement AJAX in the embedded form after that.
Is there any other better way to embed a form?
Note: There is no other option then to embed a separate form to the current form.