I print the comment form for each node in my view with the Views PHP module. The URL of the view is user/%/selection, and the code I am using is the following one.

$comment = new stdClass;
$comment->nid = $row->nid;
$form = drupal_get_form('comment_node_MYCONTENTTYPE_form', $comment);
$form['#action'] = url('user/'.$row->uid.'/selection');
print render($form);

When the form is submitted, I get /node/nid#comment-17 as URL.

Could you explain why $form['#action'] doesn't work?

1 Answer 1


Instead of this method, why cannot a new submit handler be written? so that you can use drupal_goto there and redirect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.