<p>Ahh this is a bit misleading because the docs don't really spell it out. "formHandle" according to the docs really feels like it might be the variable you set your form to, but it's literally the form handle you got when you titled your form in the CMS.</p>

<p>So if your form starts with:</p>

<p><code>{% set apple = craft.amForms.getForm('fireTruck') %}</code></p>

<p>your error code needs to be this:</p>

<pre><code>{% if fireTruck is defined %}
    {{ errorList(fireTruck.getErrors('someField')) }}
{% endif %}
</code></pre>

<p>and <strong><em>not</em></strong> this:</p>

<pre><code>{% if apple is defined %}
    {{ errorList(apple.getErrors('someField')) }}
{% endif %}
</code></pre>

CC BY-SA 3.0
2017-09-03T00:48:30.790Z
2017-09-03T00:48:30.790Z
Ryan
<p>I had the same issue this morning, after trial and error I got it working with the following code</p>

<pre><code>{% set form = craft.amForms.getForm('contactForm') %}
{% from _self import errorList %}

{% macro errorList(errors) %}
    {% if errors %}
        &lt;ul class="errors"&gt;
            {% for error in errors %}
               &lt;li&gt;{{ error }}&lt;/li&gt;
            {% endfor %}
        &lt;/ul&gt;
    {% endif %}
{% endmacro %}

{% if craft.request.getParam('submitted') == form.handle %}
    &lt;p class="submit-notification"&gt;{{ form.afterSubmitText|default('Thanks for your submission.'|t) }}&lt;/p&gt;

{% else %}
    {%- set submitValue = (form.submitButton ? form.submitButton : 'Submit'|t) -%}

    &lt;form class="contact-form" method="post" action="#form" accept-charset="UTF-8"&gt;
        {{ getCsrfInput() }}

        {# This should always be here! #}
        &lt;input type="hidden" name="action" value="amForms/submissions/saveSubmission"&gt;

        {# Insert your form's handle. #}
        &lt;input type="hidden" name="handle" value="{{ form.handle }}"&gt;

        {# Optional: Anti-spam protection. #}
        {{ craft.amForms.displayAntispam() }}


        {# Place the HTML of your fields here #}

        &lt;input type="text" id="frm_fullName" name="fields[fullName]" placeholder="Uw naam" value="{% if formHandle.fullName is defined %}{{ formHandle.fullName }}{% endif %}"&gt;
        {% if contactForm is defined %}
            {{ errorList(contactForm.getErrors('fullName')) }}
        {% endif %}

        &lt;input type="text" id="frm_telephoneNumber" name="fields[telephoneNumber]" placeholder="Telefoonnummer" value="{% if formHandle.telephoneNumber is defined %}{{ formHandle.telephoneNumber }}{% endif %}"&gt;
        {% if contactForm is defined %}
            {{ errorList(contactForm.getErrors('telephoneNumber')) }}
        {% endif %}

        &lt;textarea id="form_comment" name="fields[comment]" value="{% if formHandle.comment is defined %}{{ formHandle.comment }}{% endif %}" placeholder="Uw vraag" rows="4"&gt;&lt;/textarea&gt;
        {% if contactForm is defined %}
            {{ errorList(contactForm.getErrors('comment')) }}
        {% endif %}

        &lt;div class="submit-button"&gt;
            &lt;input type="submit" value="{{ submitValue }}"&gt;
        &lt;/div&gt;

    &lt;/form&gt;

{% endif %}
</code></pre>

<p>Try to change your markup from</p>

<pre><code>{% if form is defined %}
    {{ errorList(form.getErrors('message')) }}
{% endif %}
</code></pre>

<p>To</p>

<pre><code>{% if contactForm is defined %}
    {{ errorList(form.getErrors('message')) }}
{% endif %}
</code></pre>

<p>Hopefully this helps</p>

CC BY-SA 3.0
2017-07-18T09:06:52.843Z
I tried this as well. But now the errors show already on page load not on submit.
KSPR
CC BY-SA 3.0
2017-07-18T08:45:31.517Z
2017-07-18T08:45:31.517Z
Danny Klaren
<p>I have this form (<a href="https://github.com/am-impact/amforms" rel="nofollow noreferrer">am forms plugin</a>):</p>

<pre><code>{% macro errorList(errors) %}
  {% if errors %}
      &lt;ul class="errors"&gt;
          {% for error in errors %}
              &lt;li&gt;{{ error }}&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  {% endif %}
{% endmacro %}

{% from _self import errorList %}

{% set form = craft.amForms.getForm('contactForm') %}

&lt;form method="post" action="" accept-charset="UTF-8"&gt;

  {{ getCsrfInput() }}
  &lt;input type="hidden" name="action" value="amForms/submissions/saveSubmission"&gt;
  &lt;input type="hidden" name="handle" value="{{ form.handle }}"&gt;



   &lt;label for="frm_message"&gt;{{ 'Nachricht' | t }}*&lt;/label&gt;
   &lt;textarea id="frm_message" name="fields[message]" value="{% if formHandle.message is defined %}{{ formHandle.message }}{% endif %}"&gt;&lt;/textarea&gt;
    {% if form is defined %}
        {{ errorList(form.getErrors('message')) }}
    {% endif %}


  &lt;input type="submit" value="Submit"&gt;

&lt;/form&gt;
</code></pre>

<p>This is not displaying any errors if the field is empty. What do I miss? I made the field required in the CP but the macro is not showing when hitting "submit" with the field empty.</p>

<error-handling><plugin-amforms>
amforms no error handling
# amforms no error handling

(Asked by: username_0 on 2017-07-18)

I have this form (am forms plugin):
{% macro errorList(errors) %}
  {% if errors %}
      
          {% for error in errors %}
              {{ error }}
          {% endfor %}
      
  {% endif %}
{% endmacro %}

{% from _self import errorList %}

{% set form = craft.amForms.getForm('contactForm') %}



  {{ getCsrfInput() }}
  
  



   {{ 'Nachricht' | t }}*
   
    {% if form is defined %}
        {{ errorList(form.getErrors('message')) }}
    {% endif %}


  



This is not displaying any errors if the field is empty. What do I miss? I made the field required in the CP but the macro is not showing when hitting "submit" with the field empty.

**Tags:** error-handling, plugin-amforms


---

## 2 answers

### Answer by username_1 on 2017-09-03. Score: 1 | Accepted answer

Ahh this is a bit misleading because the docs don't really spell it out. "formHandle" according to the docs really feels like it might be the variable you set your form to, but it's literally the form handle you got when you titled your form in the CMS.
So if your form starts with:
{% set apple = craft.amForms.getForm('fireTruck') %}
your error code needs to be this:
{% if fireTruck is defined %}
    {{ errorList(fireTruck.getErrors('someField')) }}
{% endif %}

and not this:
{% if apple is defined %}
    {{ errorList(apple.getErrors('someField')) }}
{% endif %}


---

### Answer by username_2 on 2017-07-18. Score: 0

I had the same issue this morning, after trial and error I got it working with the following code
{% set form = craft.amForms.getForm('contactForm') %}
{% from _self import errorList %}

{% macro errorList(errors) %}
    {% if errors %}
        
            {% for error in errors %}
               {{ error }}
            {% endfor %}
        
    {% endif %}
{% endmacro %}

{% if craft.request.getParam('submitted') == form.handle %}
    {{ form.afterSubmitText|default('Thanks for your submission.'|t) }}

{% else %}
    {%- set submitValue = (form.submitButton ? form.submitButton : 'Submit'|t) -%}

    
        {{ getCsrfInput() }}

        {# This should always be here! #}
        

        {# Insert your form's handle. #}
        

        {# Optional: Anti-spam protection. #}
        {{ craft.amForms.displayAntispam() }}


        {# Place the HTML of your fields here #}

        
        {% if contactForm is defined %}
            {{ errorList(contactForm.getErrors('fullName')) }}
        {% endif %}

        
        {% if contactForm is defined %}
            {{ errorList(contactForm.getErrors('telephoneNumber')) }}
        {% endif %}

        
        {% if contactForm is defined %}
            {{ errorList(contactForm.getErrors('comment')) }}
        {% endif %}

        
            
        

    

{% endif %}

Try to change your markup from
{% if form is defined %}
    {{ errorList(form.getErrors('message')) }}
{% endif %}

To
{% if contactForm is defined %}
    {{ errorList(form.getErrors('message')) }}
{% endif %}

Hopefully this helps

> **Comments:**
> **username_0**: I tried this as well. But now the errors show already on page load not on submit.  

---

