Blog comment validation messages not showing

Brendan Falkowski's Avatar

Brendan Falkowski

19 Feb, 2012 10:59 PM via web

Noticed today that comment validation messages don't appear in the frontend (errors or success). For example, click submit without filling in the form: http://gravitydept.com/blog/a-way-forward/#comment-form

No error warnings appear, but they're coded into the template: blog.post.tpl

    {% if message %}
      <p class="respond-message">{{ message }}</p>
    {% endif %}

    {% if errors %}
      <ul class="respond-errors">
        {% for error in errors %}
          <li>{{ error | textilize }}</li>
        {% endfor %}
      </ul>
    {% endif %}
  1. 2 Posted by Jonathan Hoyt on 20 Feb, 2012 04:46 PM

    Jonathan Hoyt's Avatar

    Here's Brandon's comment form, I think he handles errors a bit differently.

        {% if item.accepting_comments? %}
          <h2>Post a Comment</h2>
          {% commentform %}
            {% if message %}
              <p class="message">{{ message }}</p>
            {% else %}
              {% if errors %}
                <ul class="message">
                  {% for error in errors %}
                    <li>{{ error }}</li>
                  {% endfor %}
                </ul>
              {% endif %}
    
              <div class="meta">
                <div>{{ form.name_label }}  {{ form.name_field }}</div>
                <div>{{ form.email_label }} {{ form.email_field }}</div>
                <div>{{ form.url_label }}   {{ form.url_field }}</div>
              </div>
              <div class="body">
                {{ form.body_field }}
                <p class="note">Comments use <strong>textile</strong>. Anonymous comments will be deleted.</p>
    
                <div class="buttons"><button type="submit"><span>Post Your Comment</span></button></div>
              </div>
            {% endif %}
          {% endcommentform %}
        {% endif %}
    
  2. Jonathan Hoyt closed this discussion on 20 Feb, 2012 04:46 PM.

  3. Brendan Falkowski re-opened this discussion on 20 Feb, 2012 06:31 PM

  4. 3 Posted by Brendan Falkowski on 20 Feb, 2012 06:31 PM

    Brendan Falkowski's Avatar

    Thanks Jonathan, found the fix. The {% if message %} and {% if errors %} must be inside the {% commentform %} declaration.

    Would be really nice to have these form constraints and template tags documented over here: http://docs.harmonyapp.com/

  5. John Nunemaker closed this discussion on 07 Mar, 2012 04:44 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM