Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-23T22:57:23.500Z
Answers.LastActivityDate: 2016-03-23T22:57:23.500Z
Answers.UserDisplayName: Brian L
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-20T14:54:16.643Z
Answers.Text: 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.
Answers.UserDisplayName: Brian Liddell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-25T10:44:30.587Z
Answers.Text: @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
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-18T23:47:06.033Z
Answers.LastActivityDate: 2016-03-18T23:47:06.033Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-18T17:04:48.653Z
Comments.Text: Anything relevant in `craft/storage/runtime/logs`, or a dump of errors (`{{ dump(errors) }}`)?
Comments.UserDisplayName: Matt Stein
Tags: <plugin-contactform>
Title: Missing error messages using Craft contact form plugin
ThreadText: # 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 %}
          <ul class="errors">
            {% for error in errors %}
                  <li>{{ error }}</li>
            {% endfor %}
          </ul>
        {% endif %}
      {% endmacro %}
  
      {% from _self import errorList %}
  
      <form method="post" action="" accept-charset="UTF-8">
  
        <input type="hidden" name="action" value="contactForm/sendMessage">
        <input type="hidden" name="redirect" value="thanks">
  
        <div class="row">
          <div class="compact-2 columns">
            <div class="radio-group">Subject</div>
          </div>
          <div class="compact-10 columns">
            <input type="radio" name="message[Subject][]" value="Booking">
            <label class="radio">Booking</label>
            <input type="radio" name="message[Subject][]" value="Enquiry">
            <label class="radio">Enquiry</label>
            <input type="radio" name="message[Subject][]" value="Anything else"><label class="radio">Anything else
            </label>
          </div>
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <label for="fromName">Name</label>
          </div>
          <div class="compact-10 columns">
            <input type="text" id="fromName" placeholder="Your name" name="message[Name]" value=""> 
          </div>
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <label for="fromEmail">Email</label>
          </div>
          <div class="compact-10 columns">
            <input type="text" id="fromEmail" placeholder="Your email address (required)" name="fromEmail" value="{% if message is defined %}{{ message.fromEmail }}{% endif %}">
            {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}
          </div>
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <label for="phone">Phone</label>
          </div>
          <div class="compact-10 columns">
            <input type="text" id="phone" placeholder="Your phone number" name="message[Phone]" value=""> 
          </div>
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <div class="radio-group" for="studio">Studio</div>
          </div>
          <div class="compact-10 columns">
            <input type="radio" name="message[Studio][]" value="Studio 1 double">
            <label for="Studio 1 double" class="radio">Studio 1 double</label>
            <input type="radio" name="message[Studio][]" value="Studio 2 double">
            <label for="Studio 2 double" class="radio">Studio 2 double</label>
            <input type="radio" name="message[Studio][]" value="Studio 2 twin"><label for="Studio 2 twin" class="radio">Studio 2 twin</label>
          </div> 
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <div class="radio-group" for="studio">For</div>
          </div>
          <div class="compact-10 columns">
            <input type="radio" name="message[For][]" value="Two people sharing"><label class="radio">Two people sharing</label>
            <input type="radio" name="message[For][]" value="Single occupancy"><label class="radio">Single occupancy</label>
          </div> 
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <label for="arrival">Arrival</label>
          </div>
          <div class="compact-5 columns end">
            <input type="text" id="arrival" placeholder="Date of arrival" name="message[Arrival]" value=""> 
          </div>
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <label for="nights">Nights</label>
          </div>
          <div class="compact-5 columns end">
            <input type="text" id="nights" placeholder="Number of nights" name="message[Nights]" value=""> 
          </div>
        </div>
  
        <div class="row">
          <div class="compact-2 columns">
            <label for="message">Message</label>
          </div>
          <div class="compact-10 columns">
            <textarea rows="10" cols="40" id="message" name="message[body]" placeholder="Your message here (required)" name="message" value="">{% if message is defined %}{{ message.message }}{% endif %}</textarea>
            {{ message is defined and message ? errorList(message.getErrors('message')) }} 
          </div>
        </div>
  
          <input id="preferredKitten" name="preferredKitten" type="text">
  
          <div class="row">
            <div class="small-3 compact-offset-2 columns end">
              <button type="submit" class="button button-primary">Send Message</button>
            </div>
          </div>
  
      </form>
  
  ```
  
  **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 username_3. 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**: @username_3 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  
  
  ---
  
  