Multiple forms in same page from single form builder returning the first form's value in submit I have written a single form builder and a form submit handler corresponding to that form.

What I have done is that I have rendered the form multiple times using for loop and then concatenated them into a single variable and then displayed it on a single page. 

Each form has separate submit buttons.

But the problem is that whenever I press the submit button of any of the forms I am only getting the form that was built first in the form_state['values'] in the submit handler.

For now, I have made it work by taking the form_state['input'] which seem to have the correct set of values based on the form submit clicked.

I need the corresponding form values in the submit handler. How can I achieve this?

Is this some kind of bug or am I doing it wrong?

$form_markup = '';
  foreach ($ids as $key =&gt; $value) {
    $req_form = drupal_get_form('_request_form', $value, $key, $node);
    $form_markup .= render($req_form);
  }


My form and form_submit

function _request_form($form, &amp;$form_state, $value, $key, $node) {
    $form['name'] = array(
      '#type' =&gt; 'item',
      '
    );
    $form['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; 'Ask',
    );
    return $form;
  }
}

    function _request_form_submit($form, &amp;$form_state) {
      dpm(form_state['values']);
      dpm(form_state['input']);
    }


Any help is much appreciated.
thanks.
You'll need to implement hook_forms(), so that you can create 'aliases' of your forms.

For example, let's imagine a form named 'message_form', that you want to include multiple times on the page. To do this, you append a unique number to the form name each time when calling the form:

$page = [
  'form_1' =&gt; drupal_get_form('message_form-1'),
  'form_2' =&gt; drupal_get_form('message_form-2'),
];

return $page;


Next, you implement hook_forms() to watch for form names in the format above:

function hook_forms($form_id, $args) {
  // Act on form IDs that match the pattern message_form-[NUMBER].
  if (preg_match('/^message_form-\d+$/', $form_id)) {
    // The key is the form ID that has been passed.
    $forms[$form_id] = [
      // The callback is the actual form definition to be called.
      'callback' =&gt; 'message_form',
    ];
  }
}


Now each form being put on the page will have a custom form ID and therefore the system will know which form the submitted data refers to.