Forum

Thread tagged as: Problem, Addons, Comments

Comments App not saving comments to database

I've recently upgraded Perch to v2.8.31 and the Comments app to v1.2. Since doing this the comments are no longer saved to the DB.

In the comments form, neither the parentID or the parentTitle attribute contain the value that was passed into the perch_comments_form function. After some debugging I've noticed that the parentID and parentTilte get stripped out after running the template through the apply_runtime_post_processing function. Is this the correct behaviour and would this be the reason why it's not being stored in the DB?

I've included the template string as stored in the $html variable for the perch_comments_form function before and after it's passed to the apply_runtime_post_processing function.

This is the template before passing it to the apply_runtime_post_processing function:

<perch:form template="/templates/comments/comment_form.html" id="comment" method="post" app="perch_comments">
    <fieldset>
       <legend>Leave a comment</legend>
        <div>
            <perch:label for="commentHTML">Comment</perch:label>
            <perch:input type="textarea" id="commentHTML" required="true" label="Message" rows="8" antispam="body" />
            <perch:error for="commentHTML" type="required"><p class="alert-box alert">You need to provide a comment</p></perch:error>
        </div>
        <div class="row">
            <div class="small-12 medium-6 columns">
                <perch:label for="commentName">Name</perch:label>
                <perch:input type="text" id="commentName" required="true" label="Name" antispam="name" />
                <perch:error for="commentName" type="required"><p class="alert-box alert">You need to provide a name</p></perch:error>
            </div>
            <div class="small-12 medium-6 columns">
                <perch:label for="commentEmail">Email</perch:label>
                <perch:input type="email" id="commentEmail" label="Email" antispam="email" />
                <perch:error for="commentEmail" type="format"><p class="alert-box alert">Check the format of the email</p></perch:error>
            </div>
        </div>
        <div>
            <perch:input type="hidden" id="parentID" value='production171' />
            <perch:input type="hidden" id="parentTitle" value='Production comments' />
            <perch:input type="submit" id="submitComment" class="submit-button small button radius" value="Submit" />
        </div>
    </fieldset>
    <perch:success>
        <p>Thank you. Your comment has been submitted and will appear on the site once approved.</p>
    </perch:success>
</perch:form>

This is the template after apply_runtime_post_processing, just before it's echoed out:

<form id="form1_comment" action="/productions/?slug=trailertrash" method="post">
    <fieldset>
       <legend>Leave a comment</legend>
        <div>
            <label for="form1_commentHTML">Comment</label>
            <textarea id="form1_commentHTML" name="commentHTML" cols="30" rows="8" required="required"></textarea>

        </div>
        <div class="row">
            <div class="small-12 medium-6 columns">
                <label for="form1_commentName">Name</label>
                <input id="form1_commentName" name="commentName" type="text" required="required" />

            </div>
            <div class="small-12 medium-6 columns">
                <label for="form1_commentEmail">Email</label>
                <input id="form1_commentEmail" name="commentEmail" type="email" />

            </div>
        </div>
        <div>
            <input id="form1_parentID" name="parentID" type="hidden" />
            <input id="form1_parentTitle" name="parentTitle" type="hidden" />
            <input id="form1_submitComment" name="submitComment" class="submit-button small button radius" value="Submit" type="submit" /><input type="hidden" name="cms-form" value="Y29tbWVudDpwZXJjaF9jb21tZW50czovdGVtcGxhdGVzL2NvbW1lbnRzL2NvbW1lbnRfZm9ybS5odG1sOjE0NzYxODA5MDk=" />
        </div>
    </fieldset>

</form>

Diagnostic Report:

Perch: 2.8.31, PHP: 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1, MySQL: 5.5.52, with PDO
Server OS: Linux, fpm-fcgi
Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_forms (1.8.3), perch_comments (1.2), perch_mailchimp (3.0.1)
App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_comments/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_mailchimp/runtime.php'); ?>
PERCH_LOGINPATH: /admin
PERCH_PATH: /vagrant/playsthething/public/admin
PERCH_CORE: /vagrant/playsthething/public/admin/core
PERCH_RESFILEPATH: /vagrant/playsthething/public/admin/resources
Image manipulation: GD Imagick
PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: playsthething.192.168.22.10.xip.io
DOCUMENT_ROOT: /vagrant/playsthething/public
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Damian Lewis

Damian Lewis 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Those two fields have invalid quotes on them:

<perch:input type="hidden" id="parentID" value='production171' /> 
<perch:input type="hidden" id="parentTitle" value='Production comments' />

Just worked out the problem, my IDE squawks at the use of nested double quotes as used for the perch:comments tag inside the value attribute:

<perch:input type="hidden" id="parentID" value="<perch:comments id="parentID" />" />

Thanks Drew, noticed the problem after submitting the issue.