I have used views to display nodes with their comments on one page.

This means if there are say 10 nodes on the page, there are 10 comment submission forms.

When I submit the comment form, it submits to the node page the comment form is for, not the view page I submitted it from.

Is there a way to override this using hook_form_alter or the &destination option for example?

Comments

joachim’s picture

Yes, you can change the form's destination in hook_form_alter -- see the FormAPI reference for how.

stephenrobinson’s picture

use theme developer to give you a list of candidate hook names, probably

MYTHEMENAME_comment_form_alter(&$form, $form_state, $form_id)
MYMODULENAME_comment_form_alter(&$form, $form_state, $form_id)

see http://api.drupal.org/api/function/comment_form_alter/6

joachim’s picture

That's for theme functions. Hook_form_alter is not a theme function.

jptaranto’s picture

I'm wondering how to do this in Drupal 7.

Form id's for comment form's seem to be node type specific so instead of being 'comment_form' or whatever it was in D6, its now "comment_node_NODE_TYPE_form"...

I need to have one function that changes all comment types for all forms, but can't figure out how.

jptaranto’s picture

Ha - figured it out now. Use:

hook_form_comment_form_alter(&$form, &$form_state) {
 // Form alter here
};
tinny’s picture

oops. wrong thread.

aburrows’s picture

Comments are now an entity in Drupal 7, so you can modify what fields display in them