Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-03T00:48:30.790Z
Answers.LastActivityDate: 2017-09-03T00:48:30.790Z
Answers.UserDisplayName: Ryan
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-18T09:06:52.843Z
Answers.Text: I tried this as well. But now the errors show already on page load not on submit.
Answers.UserDisplayName: KSPR
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-18T08:45:31.517Z
Answers.LastActivityDate: 2017-07-18T08:45:31.517Z
Answers.UserDisplayName: Danny Klaren
Body: <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>
  
Tags: <error-handling><plugin-amforms>
Title: amforms no error handling
ThreadText: # amforms no error handling
  
  (Asked by: username_0 on 2017-07-18)
  
  I have this form ([am forms plugin](https://github.com/am-impact/amforms)):
  
  ```
  {% macro errorList(errors) %}
    {% if errors %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
  {% endmacro %}
  
  {% from _self import errorList %}
  
  {% set form = craft.amForms.getForm('contactForm') %}
  
  <form method="post" action="" accept-charset="UTF-8">
  
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="amForms/submissions/saveSubmission">
    <input type="hidden" name="handle" value="{{ form.handle }}">
  
     <label for="frm_message">{{ 'Nachricht' | t }}*</label>
     <textarea id="frm_message" name="fields[message]" value="{% if formHandle.message is defined %}{{ formHandle.message }}{% endif %}"></textarea>
      {% if form is defined %}
          {{ errorList(form.getErrors('message')) }}
      {% endif %}
  
    <input type="submit" value="Submit">
  
  </form>
  
  ```
  
  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 %}
          <ul class="errors">
              {% for error in errors %}
                 <li>{{ error }}</li>
              {% endfor %}
          </ul>
      {% endif %}
  {% endmacro %}
  
  {% if craft.request.getParam('submitted') == form.handle %}
      <p class="submit-notification">{{ form.afterSubmitText|default('Thanks for your submission.'|t) }}</p>
  
  {% else %}
      {%- set submitValue = (form.submitButton ? form.submitButton : 'Submit'|t) -%}
  
      <form class="contact-form" method="post" action="#form" accept-charset="UTF-8">
          {{ getCsrfInput() }}
  
          {# This should always be here! #}
          <input type="hidden" name="action" value="amForms/submissions/saveSubmission">
  
          {# Insert your form's handle. #}
          <input type="hidden" name="handle" value="{{ form.handle }}">
  
          {# Optional: Anti-spam protection. #}
          {{ craft.amForms.displayAntispam() }}
  
          {# Place the HTML of your fields here #}
  
          <input type="text" id="frm_fullName" name="fields[fullName]" placeholder="Uw naam" value="{% if formHandle.fullName is defined %}{{ formHandle.fullName }}{% endif %}">
          {% if contactForm is defined %}
              {{ errorList(contactForm.getErrors('fullName')) }}
          {% endif %}
  
          <input type="text" id="frm_telephoneNumber" name="fields[telephoneNumber]" placeholder="Telefoonnummer" value="{% if formHandle.telephoneNumber is defined %}{{ formHandle.telephoneNumber }}{% endif %}">
          {% if contactForm is defined %}
              {{ errorList(contactForm.getErrors('telephoneNumber')) }}
          {% endif %}
  
          <textarea id="form_comment" name="fields[comment]" value="{% if formHandle.comment is defined %}{{ formHandle.comment }}{% endif %}" placeholder="Uw vraag" rows="4"></textarea>
          {% if contactForm is defined %}
              {{ errorList(contactForm.getErrors('comment')) }}
          {% endif %}
  
          <div class="submit-button">
              <input type="submit" value="{{ submitValue }}">
          </div>
  
      </form>
  
  {% 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.  
  
  ---
  
  