I'm using global fields on a multi language site to get the appropriate content depending on the locales used. Sof far so good.
However on a form page (sproutforms) these globals empty out after the form is submitted while an (input) error occurred.
How to overcome this issue?
{# FORM #}
<section class="col-sm-6 col-md-6" style="padding-bottom: 40px;">
{# Prepare our error macro #}
{% macro errorList(errors) %}
{# To display errors, you want to make sure errors exist, and then you can loop through and display them #}
{% if errors %}
{% for error in errors %}
{{ error }}</br>
{% endfor %}
{% endif %}
{% endmacro %}
{% from _self import errorList %}
{# Check if we should display or form or thank you message #}
{% if craft.request.getParam('message') == ('thank-you' or 'bedankt-voor-uw-aanvraag') %}
{# Check for the last entry submitted #}
{% set lastEntry = craft.sproutForms.lastEntry() %}
{% if lastEntry %}
{# If the last entry exists, we can output any of the variables that were present in the form submission. #}
<div class="alert fade in">
<i class="fa fa-cloud-download alert-icon"></i>
<button type="button" class="close" data-dismiss="alert">×</button>
<p>Thanks <strong>{{ lastEntry.fullName }}</strong>! We'll be in touch soon! Did you know you can display any of the values that were submitted in the form? Here's a list of all the values in the last form submission:</p>
</div>
{% endif %}
{% else %}
<form id="contactform" class="form-box register-form contact-form" method="post" accept-charset="utf-8">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="sproutForms/entries/saveEntry">
<input type="hidden" name="handle" value="contact">
{% if craft.locale == 'en_us' %}
<input type="hidden" name="redirect" value="/en/contact?message=thank-you">
{% endif %}
{% if craft.locale == 'nl_nl' %}
<input type="hidden" name="redirect" value="/contact?message=bedankt-voor-uw-aanvraag">
{% endif %}
<h3 class="title">{{ formsAndButtons.contact }}</h3>
<div id="success"></div>
<label class="control-label" >{{ formsAndButtons.yourName }} <span class="required">*</span></label>
<input class="form-control" type="text" id="textName" name="fields[fullName]" {%- if contact is defined %}value="{{ contact.fullName }}"{% endif -%}>
{% if contact is defined %}
<div class="error">
{{ errorList(contact.getErrors('fullName')) }}
</div>
{% endif %}
<label>{{ formsAndButtons.email }} <span class="required">*</span></label>
<input class="form-control" type="email" id="textEmail" name="fields[email]" {%- if contact is defined %}value="{{ contact.email }}"{% endif -%}>
{% if contact is defined %}
<div class="error">
{{ errorList(contact.getErrors('email')) }}
</div>
{% endif %}
<label>{{ formsAndButtons.telephone }} </label>
<input class="form-control" type="text" id="textPhone" name="fields[phone]" {%- if contact is defined %}value="{{ contact.phone }}"{% endif -%}>
{% if contact is defined %}
<div class="error">
{{ errorList(contact.getErrors('phone')) }}
</div>
{% endif %}
<label>{{ formsAndButtons.comment }} <span class="required">*</span></label>
<textarea class="form-control" id="fields-message" name="fields[message]">{%- if contact is defined %}{{ contact.message }}{% endif -%}</textarea>
{% if contact is defined %}
<div class="error">
{{ errorList(contact.getErrors('message')) }}
</div>
{% endif %}
<div class="clearfix"></div>
<div class="buttons-box clearfix">
<input class="btn btn-default" type="submit" value="{{ login.submit }}">
<span class="required"><b>*</b> {{ login.requiredField }}</span>
</div>
</form>
{% endif %}
</section>