Jump to content

Comments Not Saving


Rhen GWL
 Share

Recommended Posts

I'm trying to install comments on two of my clients' websites. In both cases, I'm able to display the comment submission form, but the form submissions are not being saved or display. Once I click the submit button, I'm directed to the homepage where #CommentForm is appended to the end of the URL. I have looked through countless forums and Google searches, but I can't find any advice that has fixed this issue. I have followed the instructions from https://processwire.com/docs/modules/guides/comments/ exactly as described, and I'm getting no where.

Like I said, this is set up on two different websites and I'm seeing the same issues with both. I assume it's some issue with connecting with a database, but I don't see anything in the instructions on PW's website that says I need to do anything there.

Link to comment
Share on other sites

Hi @Rhen GWL and welcome to the PW forums.

By any chance do you have the template setting "Should page URLs end with a slash?" set to "No"?

2019-04-30_110712.png.a9750fe8950143f5558e3cfefa92625d.png

There seems to be an issue with the default action of the comments form that will submit the form to the parent page if the current page has no trailing slash.

I opened a GitHub issue here, and in the meantime until Ryan responds you can override the default form action in the $options array for renderForm():

echo $page->comments->renderForm(array('attrs' => array('action' => $page->url)));

 

Link to comment
Share on other sites

This is probably too basic of answer, but I believe you can install the "Regular Blog" (site-regular) Profile that comes with Processwire on a test site to see and test how comments work.  You can also compare your code with it.

You can read more about it at https://processwire.com/blog/posts/introducing-a-new-processwire-site-profile/

Link to comment
Share on other sites

 
 
 
2
On 4/29/2019 at 6:09 PM, Robin S said:

Hi @Rhen GWL and welcome to the PW forums.

By any chance do you have the template setting "Should page URLs end with a slash?" set to "No"?

2019-04-30_110712.png.a9750fe8950143f5558e3cfefa92625d.png

 There seems to be an issue with the default action of the comments form that will submit the form to the parent page if the current page has no trailing slash.

I opened a GitHub issue here, and in the meantime until Ryan responds you can override the default form action in the $options array for renderForm():


echo $page->comments->renderForm(array('attrs' => array('action' => $page->url)));

 

My template is set to end with a slash.

But I implemented your override and that worked!! Thanks!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...