At Drupal 7, how do I submit a form without a redirect to the comment page or message page?


I have made a message form and comment form as blocks and embedded the blocks in a view, whenever I submit the message / comment form, the page will redirect to the message / comment page.

This is code:

 $node = node_load($nid); // $nid contains the node id
 $comment = new stdClass;
 $comment->nid = arg(2);
 $form = drupal_get_form('comment_node_project_form', $comment);
 print render($form);

How should I do to submit the form without redirecting ? on the $form variable ?

It sounds like you are either going to need $form_state['redirect'] (though in this case you may have to to have to unset it, since your form is already redirecting to a new page) or if you mean to say you don't want to have the page refresh at all, you'll need to ajax-ify your form.