comment form in drupal views

1k views Asked by At

I want to add separate comment form for each node showed in a view. I used template row using following code:

$comment = new stdClass;
$comment->nid = strip_tags($fields['nid']->content);
$form = drupal_get_form('comment_form', $comment);
print render($form);

Form is showed, but doesnt work properly. When I click on save, instead of saving the comment it redirect me to following url: comment/reply/35 (in case I try to add a comment for node 35)

Regards

1

There are 1 answers

0
Mario Araque On

You can do this using hook_form_alter, you may change $form['#action'] and edit the action form to your custom url.

This post can be helpful to change the destination url after submitting the comment.