Re-populate additional fields on Contact Form on failure of form validation I'm using additional fields on my contact form. I want to re-populate the additional fields if/when the form fails validation, but it's not working so far.

To re-populate a standard field, the code uses an attribute of message using dot syntax…

&lt;input name="fromName" id="fromName" value="{% if message is defined %}{{ message.fromName }}{% endif %}" type="text"&gt;


But for additional fields the value is stored as an attribute of message.message using the subscript syntax (the use of square brackets below)…

&lt;input name="message[Phone]" id="phone" type="text" value=""&gt;


I'm having trouble accessing the substring value on message.message. In my specific example, I have several radio buttons that need their selections remembered in case anything goes wrong. Here's what I expected to work…

{% for course in courses %}
    &lt;input id={{ course.slug }}" name="message[Course]" type="radio" value="{{ course }}"
         {% if message is defined and message.message[Course] == course %}
             checked="checked"
         {% endif%}&gt;
{% endfor %}


However, this code outputs the template error:

Variable "Course" does not exist.


How can I re-populate the additional fields for the contact form plugin?
From the changelog:


  1.7.0
  
  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'].


So I think you should be using message.messageFields[Course] rather than message.message[Course]