Answers.Body: <p><strong>TL;DR</strong><br>
  This issue has been resolved and will be available in the next release of <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms" rel="nofollow">Sprout Forms</a> (0.8.4)</p>
  
  <p>The issue was caused by our use of <code>context switching</code> for custom content tables in combination with <code>renderObjectTemplate()</code>, the latter of which initializes the <code>twig environment</code> and loads globals if not already loaded. This initialization is <code>context sensitive</code> so since we needed to switch context and then use <code>renderObjectTemplate()</code> before we could switch the <code>context</code> back, <code>globals</code> would inherit the content model from the form entry itself, not their actual content.</p>
  
  <p>We fixed this issue by initializing the environment before any context switching is done.</p>
  
  <p><a href="http://selv.in" rel="nofollow">Selvin Ortiz</a><br>
  <strong>Barrel Strength Design</strong></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T21:03:53.380Z
Answers.LastActivityDate: 2015-01-09T21:03:53.380Z
Answers.UserDisplayName: Selvin Ortiz
Body: <p>I'm using global fields on a multi language site to get the appropriate content depending on the locales used. Sof far so good.</p>
  
  <p>However on a form page (sproutforms) these globals empty out after the form is submitted while an (input) error occurred.</p>
  
  <p>How to overcome this issue?</p>
  
  <pre><code>                {# FORM #}
              &lt;section class="col-sm-6 col-md-6" style="padding-bottom: 40px;"&gt;
  
              {# 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 }}&lt;/br&gt;
                      {% 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. #}
  
                      &lt;div class="alert fade in"&gt;
                          &lt;i class="fa fa-cloud-download alert-icon"&gt;&lt;/i&gt;
                          &lt;button type="button" class="close" data-dismiss="alert"&gt;×&lt;/button&gt;
                          &lt;p&gt;Thanks &lt;strong&gt;{{ lastEntry.fullName }}&lt;/strong&gt;! 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:&lt;/p&gt;
                      &lt;/div&gt;
  
  
                  {% endif %}
  
              {% else %}
  
                  &lt;form id="contactform" class="form-box register-form contact-form" method="post" accept-charset="utf-8"&gt;
                      {{ getCsrfInput() }}
                      &lt;input type="hidden" name="action" value="sproutForms/entries/saveEntry"&gt;
                      &lt;input type="hidden" name="handle" value="contact"&gt;
                      {% if craft.locale == 'en_us' %}
                      &lt;input type="hidden" name="redirect" value="/en/contact?message=thank-you"&gt;
                      {% endif %}
                      {% if craft.locale == 'nl_nl' %}
                      &lt;input type="hidden" name="redirect" value="/contact?message=bedankt-voor-uw-aanvraag"&gt;
                      {% endif %}
  
                      &lt;h3 class="title"&gt;{{ formsAndButtons.contact }}&lt;/h3&gt;
                      &lt;div id="success"&gt;&lt;/div&gt;
  
                      &lt;label class="control-label" &gt;{{ formsAndButtons.yourName }} &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                      &lt;input class="form-control"  type="text" id="textName" name="fields[fullName]" {%- if contact is defined %}value="{{ contact.fullName }}"{% endif -%}&gt;
                      {% if contact is defined %}
                      &lt;div class="error"&gt;
                          {{ errorList(contact.getErrors('fullName')) }}
                      &lt;/div&gt;
                      {% endif %}
  
                      &lt;label&gt;{{ formsAndButtons.email }} &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                      &lt;input class="form-control" type="email" id="textEmail" name="fields[email]" {%- if contact is defined %}value="{{ contact.email }}"{% endif -%}&gt;
                      {% if contact is defined %}
                      &lt;div class="error"&gt;
                          {{ errorList(contact.getErrors('email')) }}
                      &lt;/div&gt;
                      {% endif %}
  
                      &lt;label&gt;{{ formsAndButtons.telephone }} &lt;/label&gt;
                      &lt;input class="form-control"  type="text" id="textPhone" name="fields[phone]" {%- if contact is defined %}value="{{ contact.phone }}"{% endif -%}&gt;
                      {% if contact is defined %}
                      &lt;div class="error"&gt;
                          {{ errorList(contact.getErrors('phone')) }}
                      &lt;/div&gt;
                      {% endif %}
  
                      &lt;label&gt;{{ formsAndButtons.comment }} &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                      &lt;textarea class="form-control" id="fields-message" name="fields[message]"&gt;{%- if contact is defined %}{{ contact.message }}{% endif -%}&lt;/textarea&gt;
                      {% if contact is defined %}
                      &lt;div class="error"&gt;
                          {{ errorList(contact.getErrors('message')) }}
                      &lt;/div&gt;
                      {% endif %}
  
                      &lt;div class="clearfix"&gt;&lt;/div&gt;
  
                      &lt;div class="buttons-box clearfix"&gt;
                          &lt;input class="btn btn-default" type="submit" value="{{ login.submit }}"&gt;
                          &lt;span class="required"&gt;&lt;b&gt;*&lt;/b&gt; {{ login.requiredField }}&lt;/span&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
  
              {% endif %}
              &lt;/section&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-08T19:04:20.100Z
Comments.Text: Sounds like a Sprout Forms bug to me, no? Have you tried contacting them?
Comments.UserDisplayName: Brad Bell
Tags: <form><globals><plugin-sproutforms>
Title: Globals fields empty after form errors
ThreadText: # Globals fields empty after form errors
  
  (Asked by: username_0 on 2015-01-08)
  
  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>
  
  ```
  
  **Tags:** form, globals, plugin-sproutforms
  
  > **Comments:**
  > **username_1**: Sounds like a Sprout Forms bug to me, no? Have you tried contacting them?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-01-09. Score: 2
  
  **TL;DR**  
  This issue has been resolved and will be available in the next release of [Sprout Forms](http://sprout.barrelstrengthdesign.com/craft-plugins/forms) (0.8.4)
  
  The issue was caused by our use of `context switching` for custom content tables in combination with `renderObjectTemplate()`, the latter of which initializes the `twig environment` and loads globals if not already loaded. This initialization is `context sensitive` so since we needed to switch context and then use `renderObjectTemplate()` before we could switch the `context` back, `globals` would inherit the content model from the form entry itself, not their actual content.
  
  We fixed this issue by initializing the environment before any context switching is done.
  
  [username_2](http://selv.in)  
  **Barrel Strength Design**
  
  
  ---
  
  