0

I have a themed node view page (having an alias URL) where I have also themed the comments forms and comment threads.

A code snippet for that :

$form_template = drupal_get_form("comment_node_image_gallery_form", (object) array('nid' => $variables['nid']));
print drupal_render($form_template);

It all works fine but with one problem, when I try to post an empty comment thread, it takes me to the default comment-reply page and not in the alias page (http://mysite.com/comment/reply/138). Why is this happening and what is the way to stop this so that it gets redirected to the original aliased page when it gets stopped in the validation procedure?

FYI : However, when I submit a valid comment it takes me to the aliased page after successful submission.

Hope I made myself clear and thanks in advance...

  • Well, after another round of search I found making your comment form action blank (that is submit in the current page), it keeps you in the current aliased page after it gets validated. $form['#action'] = ''; // In form alter However, this presents with a new challenge, now the validation error are not getting shown. Any ideas why? I will keep you updated if I can find anything... – Pratip Ghosh Jan 28 '14 at 14:28
  • "validation error are not getting shown. Any ideas why?" probably in your customized template they are simply never printed. If you will ask a question about that, I think I can provide a workaround – Mołot Jan 28 '14 at 14:31
  • Do I need to raise a separate question for that? Or can you share your workaround as an answer to this question itself? I tried to catch the error from form_get_errors(), but it is coming empty. – Pratip Ghosh Jan 28 '14 at 14:34
  • Displaying form errors is not the same as staying on the same alias after form submit. Separate issues == separate questions, that's how it works, if you don't want your questions to be put on hold as too broad. – Mołot Jan 28 '14 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.