2

I have a guest entry form that's working fine. I'm using Craft-supplied code:

{% macro errorList(errors) %}
  {% if errors %}
    {% for error in errors %}
      {{ error }}{% if not loop.last %}, {% endif %} 
    {% endfor %}
  {% endif %}
{% endmacro %}

And it works fine - field by field:

{% if entry is defined %}
  <p class="help alert">{{ errorList(entry.getErrors('title')) }}</p>
{% endif %}

But I can't figure out how to check if there are any errors (and error in any field) so I can display a notification at the top of the page: "There were some problems with your submission".

{% if errorList(entry.getErrors())|length }}

doesn't work.

1 Answer 1

2

You can use this

{% if entry.hasErrors() %}
    Render a message here
{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.