We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Problem, Error, Comments

Extra template field not showing in moderated comments

In my template, I have a select field that lets a user choose a star rating for a product. It works fine when bypassing moderation with a Perch admin login, but when another user submits the form and the comment is listed on the site, it strips the content from within that field. Is there another place I need to register this additional field within the plugin so the system doesn't kill it on upload?

Comments Form:

<perch:form id="comment" method="post" app="perch_comments">
    <fieldset>
        <h3>Write a Review</h3>
        <div>
            <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">Required</perch:error>
        </div>
        <div>
            <perch:label for="commentEmail">Email</perch:label>
            <perch:input type="email" id="commentEmail" required="true" label="Email" antispam="email" />
            <perch:error for="commentEmail" type="required">Required</perch:error>
            <perch:error for="commentEmail" type="format">Check format of address</perch:error>
        </div>
        <div style="margin-top: 20px">
            <perch:label for="rating">Rating</perch:label>
            <perch:input type="select" id="rating" options="★ ★ ★ ★ ★|5, ★ ★ ★ ★|4, ★ ★ ★|3, ★ ★|2, ★|1" allowempty="false" required="true" class="rating-select" />
            <perch:error for="rating" type="required">Required</perch:error><br>
            <perch:label for="commentHTML">Comments</perch:label><br>
            <perch:input type="textarea" id="commentHTML" required="true" label="Message" antispam="body" />
            <perch:error for="commentHTML" type="required">Required</perch:error>
        </div>
        <div>
            <perch:input type="hidden" id="parentID" value="<perch:comments id="parentID" />" />
            <perch:input type="hidden" id="parentTitle" value="<perch:comments id="parentTitle" />" />
            <perch:input type="submit" id="submitComment" value="Submit" class="button" />
        </div>
    </fieldset>
    <perch:success>
        <p>Thanks for taking the time to review our product! Your comments will appear on the site once approved.</p>
    </perch:success>
</perch:form>

Comments Display:

<perch:before>
    <hr />
    <h2>Reviews</h2>
    <perch:if not-exists="commentName">
        <span id="no-reviews">There aren't any reviews for this product yet... :(<br>
        Be the first to review it!</span>
    </perch:if>
    <ul class="ratings">
</perch:before>
        <li id="comment<perch:comments id="commentID" type="hidden" />">
            <img src="//www.gravatar.com/avatar/<perch:comments id="commentEmail" type="email" label="Email" order="2" hash="md5" required="true" />?s=120&amp;d=mm" width="60" height="60" />
            <div style="display: inline-block">
                <perch:if exists="commentURL"><a href="<perch:comments id="commentURL" type="url" label="URL" order="3" />"></perch:if>
                    <strong><perch:comments id="commentName" type="text" label="Name" order="1" required="true" />
                <perch:if exists="commentURL"></a></perch:if></strong>
                <span rel="bookmark" class="date"><perch:comments id="commentDateTime" format="%b %d, %Y" type="date" time="true" label="Date" /></span>
            </div>
            <div class="comment">
                <span class="rating-display">
                    <perch:if id="rating" value="5">
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                    </perch:if>
                    <perch:if id="rating" value="4">
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="far fa-star"></i>
                    </perch:if>
                    <perch:if id="rating" value="3">
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="far fa-star"></i>
                        <i class="far fa-star"></i>
                    </perch:if>
                    <perch:if id="rating" value="2">
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="far fa-star"></i>
                        <i class="far fa-star"></i>
                        <i class="far fa-star"></i>
                    </perch:if>
                    <perch:if id="rating" value="1">
                        <i class="fas fa-star"></i>
                        <i class="far fa-star"></i>
                        <i class="far fa-star"></i>
                        <i class="far fa-star"></i>
                        <i class="far fa-star"></i>
                    </perch:if>
                </span>
                <perch:comments id="commentHTML" encode="false" html="true" type="textarea" label="Message (HTML)" order="4" required="true" />
            </div>
        </li>
<perch:after>
    </ul>
</perch:after>
Kevin Wolff

Kevin Wolff 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the field in the comment.html master template?

No. Should I add it to the basic master template and then just hide it?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Use suppress if you don't want to output the result, but yes, it needs to be in the master template.