<p>Sorry guys: It was me -- I had cached the form, and the error message works fine when I removed this. Took me a day to find. I've got a lot to learn!</p>

CC BY-SA 3.0
2016-03-23T22:57:23.500Z
2016-03-23T22:57:23.500Z
Brian L
<p>Pretty sure you just need to update to <a href="https://github.com/pixelandtonic/ContactForm#170" rel="nofollow">Contact Form 1.7.0</a>:</p>

<blockquote>
  <p>Added the ability to access individual message fields values via message.messageFields when a validation error occurred. For example, the value of the input <code>message[Phone]</code> can now be accessed via <code>message.messageFields['Phone']</code>.</p>
</blockquote>

CC BY-SA 3.0
2016-03-20T14:54:16.643Z
Thanks Brad. I updated to Contact Form 1.7, but it made no difference. Weird thing is that when I tried a test page with my form included in the body, it worked ok: ie error messages are shown. But when my form is added via a matrix block, it doesn't work correctly: ie it doesn't show any error messages.
Brian Liddell
CC BY-SA 3.0
2016-08-25T10:44:30.587Z
@bradbell Hi this works well for me when populating the field. But is it possible to return an error message for a specific field? I've tried
{{ message.messageFields['Salutation'] is defined and message.messageFields['Salutation']  ? errorList(message.getErrors('message')) }} But with no luck. Am I getting the syntax wrong or is this not an available option at this time? Cheers
Lettie
CC BY-SA 3.0
2016-03-18T23:47:06.033Z
2016-03-18T23:47:06.033Z
Brad Bell
<p>I've got a small site for a B&amp;B, entirely based on a single Craft structure.</p>

<p>Every page uses the same entry template, which extends a layout template. This layout template has header, sidebar, and footer includes. The site’s navigation is generated direct from the structure.</p>

<p>All this works well.</p>

<p>The entry template makes extensive use of matrix blocks to create different page layouts, and one of these matrix blocks is a checkbox which adds an enquiry form to the page. The template for this is based on the Craft contact form. (I started this project a while ago as a learning exercise, and I’m still on contact form version 1.4).</p>

<p>The problem is that I can’t get the error messages on the email and message fields to work. If there’s an error in the form: on submit, the browser re-loads the page and doesn’t create an email, but there are no error messages. (If there are no errors: the email is created ok, and the 'thanks' page is loaded ok.)</p>

<p>I’ve re-tested by copying the form into a single stand-alone html page, and it works perfectly like this. This isn’t a good solution, however, as I want to be able to drop the form into pages, and to make use of structure’s navigation.</p>

<p>Any pointers to where I’ve gone wrong?</p>

<p>Many thanks!</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 %}

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

      &lt;input type="hidden" name="action" value="contactForm/sendMessage"&gt;
      &lt;input type="hidden" name="redirect" value="thanks"&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;div class="radio-group"&gt;Subject&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;input type="radio" name="message[Subject][]" value="Booking"&gt;
          &lt;label class="radio"&gt;Booking&lt;/label&gt;
          &lt;input type="radio" name="message[Subject][]" value="Enquiry"&gt;
          &lt;label class="radio"&gt;Enquiry&lt;/label&gt;
          &lt;input type="radio" name="message[Subject][]" value="Anything else"&gt;&lt;label class="radio"&gt;Anything else
          &lt;/label&gt;
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;label for="fromName"&gt;Name&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;input type="text" id="fromName" placeholder="Your name" name="message[Name]" value=""&gt; 
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;label for="fromEmail"&gt;Email&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;input type="text" id="fromEmail" placeholder="Your email address (required)" name="fromEmail" value="{% if message is defined %}{{ message.fromEmail }}{% endif %}"&gt;
          {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;label for="phone"&gt;Phone&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;input type="text" id="phone" placeholder="Your phone number" name="message[Phone]" value=""&gt; 
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;div class="radio-group" for="studio"&gt;Studio&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;input type="radio" name="message[Studio][]" value="Studio 1 double"&gt;
          &lt;label for="Studio 1 double" class="radio"&gt;Studio 1 double&lt;/label&gt;
          &lt;input type="radio" name="message[Studio][]" value="Studio 2 double"&gt;
          &lt;label for="Studio 2 double" class="radio"&gt;Studio 2 double&lt;/label&gt;
          &lt;input type="radio" name="message[Studio][]" value="Studio 2 twin"&gt;&lt;label for="Studio 2 twin" class="radio"&gt;Studio 2 twin&lt;/label&gt;
        &lt;/div&gt; 
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;div class="radio-group" for="studio"&gt;For&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;input type="radio" name="message[For][]" value="Two people sharing"&gt;&lt;label class="radio"&gt;Two people sharing&lt;/label&gt;
          &lt;input type="radio" name="message[For][]" value="Single occupancy"&gt;&lt;label class="radio"&gt;Single occupancy&lt;/label&gt;
        &lt;/div&gt; 
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;label for="arrival"&gt;Arrival&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="compact-5 columns end"&gt;
          &lt;input type="text" id="arrival" placeholder="Date of arrival" name="message[Arrival]" value=""&gt; 
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;label for="nights"&gt;Nights&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="compact-5 columns end"&gt;
          &lt;input type="text" id="nights" placeholder="Number of nights" name="message[Nights]" value=""&gt; 
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="row"&gt;
        &lt;div class="compact-2 columns"&gt;
          &lt;label for="message"&gt;Message&lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="compact-10 columns"&gt;
          &lt;textarea rows="10" cols="40" id="message" name="message[body]" placeholder="Your message here (required)" name="message" value=""&gt;{% if message is defined %}{{ message.message }}{% endif %}&lt;/textarea&gt;
          {{ message is defined and message ? errorList(message.getErrors('message')) }} 
        &lt;/div&gt;
      &lt;/div&gt;

        &lt;input id="preferredKitten" name="preferredKitten" type="text"&gt;

        &lt;div class="row"&gt;
          &lt;div class="small-3 compact-offset-2 columns end"&gt;
            &lt;button type="submit" class="button button-primary"&gt;Send Message&lt;/button&gt;
          &lt;/div&gt;
        &lt;/div&gt;

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

CC BY-SA 3.0
2016-03-18T17:04:48.653Z
Anything relevant in `craft/storage/runtime/logs`, or a dump of errors (`{{ dump(errors) }}`)?
Matt Stein
<plugin-contactform>
Missing error messages using Craft contact form plugin
# Missing error messages using Craft contact form plugin

(Asked by: username_0 on 2016-03-18)

I've got a small site for a B&B, entirely based on a single Craft structure.
Every page uses the same entry template, which extends a layout template. This layout template has header, sidebar, and footer includes. The site’s navigation is generated direct from the structure.
All this works well.
The entry template makes extensive use of matrix blocks to create different page layouts, and one of these matrix blocks is a checkbox which adds an enquiry form to the page. The template for this is based on the Craft contact form. (I started this project a while ago as a learning exercise, and I’m still on contact form version 1.4).
The problem is that I can’t get the error messages on the email and message fields to work. If there’s an error in the form: on submit, the browser re-loads the page and doesn’t create an email, but there are no error messages. (If there are no errors: the email is created ok, and the 'thanks' page is loaded ok.)
I’ve re-tested by copying the form into a single stand-alone html page, and it works perfectly like this. This isn’t a good solution, however, as I want to be able to drop the form into pages, and to make use of structure’s navigation.
Any pointers to where I’ve gone wrong?
Many thanks!
    {% macro errorList(errors) %}
      {% if errors %}
        
          {% for error in errors %}
                {{ error }}
          {% endfor %}
        
      {% endif %}
    {% endmacro %}

    {% from _self import errorList %}

    

      
      

      
        
          Subject
        
        
          
          Booking
          
          Enquiry
          Anything else
          
        
      

      
        
          Name
        
        
           
        
      

      
        
          Email
        
        
          
          {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}
        
      

      
        
          Phone
        
        
           
        
      

      
        
          Studio
        
        
          
          Studio 1 double
          
          Studio 2 double
          Studio 2 twin
         
      

      
        
          For
        
        
          Two people sharing
          Single occupancy
         
      

      
        
          Arrival
        
        
           
        
      

      
        
          Nights
        
        
           
        
      

      
        
          Message
        
        
          {% if message is defined %}{{ message.message }}{% endif %}
          {{ message is defined and message ? errorList(message.getErrors('message')) }} 
        
      

        

        
          
            Send Message

**Tags:** plugin-contactform

> **Comments:**
> **username_1**: Anything relevant in `craft/storage/runtime/logs`, or a dump of errors (`{{ dump(errors) }}`)?  

---

## 2 answers

### Answer by username_2 on 2016-03-23. Score: 2

Sorry guys: It was me -- I had cached the form, and the error message works fine when I removed this. Took me a day to find. I've got a lot to learn!


---

### Answer by username_3 on 2016-03-18. Score: 1

Pretty sure you just need to update to [Contact Form 1.7.0](https://github.com/pixelandtonic/ContactForm#170):

> Added the ability to access individual message fields values via message.messageFields when a validation error occurred. For example, the value of the input `message[Phone]` can now be accessed via `message.messageFields['Phone']`.

> **Comments:**
> **username_0**: Thanks Brad. I updated to Contact Form 1.7, but it made no difference. Weird thing is that when I tried a test page with my form included in the body, it worked ok: ie error messages are shown. But when my form is added via a matrix block, it doesn't work correctly: ie it doesn't show any error messages.  
> **username_4**: @bradbell Hi this works well for me when populating the field. But is it possible to return an error message for a specific field? I've tried {{ message.messageFields['Salutation'] is defined and message.messageFields['Salutation']  ? errorList(message.getErrors('message')) }} But with no luck. Am I getting the syntax wrong or is this not an available option at this time? Cheers  

---

