FieldtypeComments: default action URL incorrect if template trailing slash setting is "No" #866
Short description of the issue
The default action URL defined in CommentForm.php is './', but if the template setting "Should page URLs end with a slash?" is "No" then the comment form submits to the parent page.
Although a custom action can be supplied to
Related forum topic: https://processwire.com/talk/topic/21427-comments-not-saving/
Suggestion for a possible fix
Set the action to the current page URL in the CommentForm constructor.
At line 80:
'action' => '',
At line 164:
// default action $this->options['attrs']['action'] = $this->wire('page')->url;
The text was updated successfully, but these errors were encountered:
Thanks @Toutouwai I've pushed an update for this, close to what you suggested. But I want to be careful only to apply it if the current request lacks a trailing slash because there are a few cases where setting it to the current page URL would break things, like if urlSegments are in use or the form is being rendered for a different page. That's why "./" is such a safe thing for the action attribute. But if the current request lacks a trailing slash, then "./" likely isn't going to be helpful, so it makes sense to use the page URL instead in that case.