1

I have a comment form that is not functioning properly.

When I try to submit a comment, nothing gets saved to the database, and instead of retuning me to the specified return URL it returns me to the same single entry page with the comment form. No error is given and no other indication that anything is wrong.

Other forms on the site like Freeform contact form works fine. Just the comment form is not working.

The weblog and entry I’m testing on both have comments enabled.

Here’s is my template code:

{exp:comment:form channel="blog" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks"}
     <fieldset>
      <ul class="formRow">
       {if logged_out}
       <li class="third">
        <label>Name <span class="req">*</span></label>
        <input type="text" name="name" value="{name}">
       </li>
       <li class="third">
        <label>Email <span class="req">*</span></label>
        <input type="text" name="email" value="{email}">
       </li>
       <li class="divider">.</li>
       {/if}
       <li class="wide">
        <label>Comment <span class="req">*</span></label>
        <textarea name="comment">{comment}</textarea>
       </li>
       {if captcha}
       <li class="divider">.</li>
       <li class="wide">
        <label>{captcha} <span class="req">*</span></label>
        <input type="text" name="captcha">
       </li>
       {/if}
       <li class="divider">.</li>
       <li class="buttons">
        <a class="btn submit arrow" href="#">Submit Comment</a>
       </li>
      </ul>
     </fieldset>
    {/exp:comment:form} 

I’ve read in other places that forcing trailing slashes on URLs or removing “www” from URLs can cause problems with form submissions. I am using .htaccess to remove index.php but I am not removing “www” nor am I forcing trailing slashes. And as said above other form submissions are working fine, just not comment form.

With no error message it’s becoming very difficult for me to tell why else it wouldn’t work.

Any ideas? How can I debug this?

2
1

You should try by using entry_id or url_title parameter with comment form tag like:

{exp:comment:form channel="blog" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks" entry_id="ENTRY_ID"}

OR

{exp:comment:form channel="blog" preview="blog/comment" form_class="default" return="{homepage}blog/comment-thanks" url_title="URL_TITLE"}

This will specify the entry on which comment will be posted.

Hope this would help you.

1
  • I was all excited about this thinking I had missed something obvious and it would solve the problem, but no, it didn't. I think by default when a comment form is inside a channel:entries loop for a single channel it assigns the comments to that entry, right? I've done it without entry_id or url_title before and never had this problem. In any case, problem still persists. Feb 11 '13 at 21:33
0

If you have the comment form code inside the channel entries loop take it out. It needs to stand alone. It will grab the url_title dynamically.

1
  • I realized that and have since corrected the issue but still no luck. Form does the same thing whether inside or outside of channel:entries. Strangely, the site I copied the the comment form code from has it's comment form inside channel:entries and it works just fine. Feb 11 '13 at 22:16

Your Answer

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

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