Rendering multiple comment form issue I have a view page on which I have rendered the comment form for each node in the field using the code below:

  $comment = new stdClass;
  $comment-&gt;nid = $n-&gt;nid;
  $form = drupal_get_form('comment_form', $comment);
  print render($form);


All my forms are printing fine, but the issue is that when I enter a message on message field and click submit, it redirect me to node page with comment form at browser top and my message is lost. If I type and click save here, my message saves without an issue.

I altered the form, added a custom_submit_handler as follows:

$form['#submit'][] = 'mymodule_custom_submit';


and defined it as:

function sparx_custom_submit($form, &amp;$form_state) {
 if(isset($form_state['custom_redirect_path'])) {
   $form_state['redirect']  = $form_state['custom_redirect_path'];
 }
}


Now the problem I am facing is that each time I try the comment is getting added to the top-most node, not to any other node.

Any suggestions please
Using the following code to print comment helped me to solve this issue:

module_load_include('inc', 'comment', 'comment.pages');
$comment_form = drupal_get_form('comment_node_&lt;content_type&gt;_form', (object) array('nid' =&gt; $nid));
print drupal_render($comment_form);