<p>You're understanding the purpose of the Hidden and Invisible fields correctly and your desired workflow is possible.</p>

<p>Let's step through each part:</p>

<h3>Hidden and Invisible Fields</h3>

<p>These fields allow you to capture values on the page that the user doesn't see.  This includes any variable available to the page your form is being submit on. The key thing to note is that by default, all variables may not be available and for some variables, you will have to take an extra step to make them available.</p>

<p>By default, the only dynamic variables available to the Hidden and Invisible fields are variables that are global in scope like <code>{{ craft.request.path }}</code> or something like that.  To make an <code>entry</code> variable available, you will need to use the <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/fields/docs/overview/hidden-field#setting-a-dynamic-value-outside-the-global-scope" rel="nofollow">addFieldVariables tag</a> on your page:</p>

<pre><code>{# This line makes the entry variable available to your 
   Hidden and Invisible Field settings. #}
{% do craft.sproutForms.addFieldVariables({ entry: entry }) %}

{# After you use addFieldVariables, you can display your Form as normal #}
{{ craft.sproutForms.displayForm('contact') }}
</code></pre>

<p>With the code above in place, you can now use any values that you want from the <code>entry</code> in your Hidden or Invisible Field Settings like <code>{{ entry.title }}</code>, <code>{{ entry.postDate|date('Y-m-d) }}</code>, <code>{{ entry.excerpt }}</code> or even loop through an array of data like Entries or Users, just like you would in your Twig template (as long as your final value can be stored in a PlainText field.  </p>

<h3>Dynamically access form data with Sprout Email</h3>

<p>To send this information in a notification email, you'll first need to setup a new Notification in Sprout Email and select the rule "When a Sprout Forms entry is saved".</p>

<p>When your form is submitted, your Sprout Email template will have your entire <code>SproutForms_Entry</code> object and all of the submitted fields available to it via the <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/email/docs/notifications/dynamic-values#using-dynamic-values-in-your-notification-entry-fields" rel="nofollow">object variable</a>.</p>

<p>So, while your entry values were available to your form as:</p>

<pre><code>{{ entry.title }}
{{ entry.postDate|date('Y-m-d) }}
{{ entry.excerpt }}
</code></pre>

<p>They will be available dynamically to your email template as:</p>

<pre><code>{{ object.title }}
{{ object.postDate|date('Y-m-d) }}
{{ object.excerpt }}
</code></pre>

CC BY-SA 3.0
2015-11-17T08:50:34.347Z
Ben thank you so much for your comprehensive answer!
Adam Menczykowski
CC BY-SA 3.0
2015-11-17T16:40:25.620Z
Hey, I'm having trouble getting the entry variable data to the email notification. I have done the following on the entry page: `{% do craft.sproutForms.addFieldVariables({ entry: entry }) %}` followed by `{{ craft.sproutForms.displayForm('eventRsvp') }}`. The event form has a field with the handle eventTitle, so its value is `{{ entry.title }}`. Then in the template for the email I'm trying to output `{{ object.eventTitle }}` - but this just returns blank.
Adam Menczykowski
CC BY-SA 3.0
2015-11-18T00:45:44.707Z
Dynamic values in notification templates may require single curly braces: `{object.eventTitle}`
Ben Parizek
CC BY-SA 3.0
2015-11-16T18:14:26.523Z
2015-11-16T18:14:26.523Z
Ben Parizek
<p>I want to gather data from the page a form is on and submit this information to the form entry. </p>

<p><strong>Use case:</strong></p>

<ul>
<li>On an 'Events' <strong>entry</strong> page <em>(the form is in the sidebar)</em></li>
<li>When the user fills in the basic form and submits, I want to get the <strong>entry's</strong> title and some custom fields in addition to what the user has filled out</li>
</ul>

<p>In short what I want the form entry to submit is: Name, Email, Tel No, Message IN ADDITION to Event Entry Title, Date, Excerpt.</p>

<p>I think this is possible with <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/examples/hidden-and-invisible-fields" rel="nofollow">hidden and invisible fields</a>, but I may misunderstand their purpose.</p>

<p>-</p>

<p>After this form has been submitted I would like Sprout Email to get a hold of this data - so I need to know how to output this data when setting up the template in the back end text area for the email as well. </p>

<p>Could anyone offer any assistance on this please? I would greatly appreciate it. Thanks!</p>

<plugin-sproutforms><plugin-sproutemail>
Sprout Forms: gather data from the page a form is on
# Sprout Forms: gather data from the page a form is on

(Asked by: username_0 on 2015-11-16)

I want to gather data from the page a form is on and submit this information to the form entry.

**Use case:**

* On an 'Events' **entry** page *(the form is in the sidebar)*
* When the user fills in the basic form and submits, I want to get the **entry's** title and some custom fields in addition to what the user has filled out

In short what I want the form entry to submit is: Name, Email, Tel No, Message IN ADDITION to Event Entry Title, Date, Excerpt.

I think this is possible with [hidden and invisible fields](http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/examples/hidden-and-invisible-fields), but I may misunderstand their purpose.

-

After this form has been submitted I would like Sprout Email to get a hold of this data - so I need to know how to output this data when setting up the template in the back end text area for the email as well.

Could anyone offer any assistance on this please? I would greatly appreciate it. Thanks!

**Tags:** plugin-sproutforms, plugin-sproutemail


---

## 1 answers

### Answer by username_1 on 2015-11-16. Score: 3 | Accepted answer

You're understanding the purpose of the Hidden and Invisible fields correctly and your desired workflow is possible.
Let's step through each part:
Hidden and Invisible Fields
These fields allow you to capture values on the page that the user doesn't see.  This includes any variable available to the page your form is being submit on. The key thing to note is that by default, all variables may not be available and for some variables, you will have to take an extra step to make them available.
By default, the only dynamic variables available to the Hidden and Invisible fields are variables that are global in scope like {{ craft.request.path }} or something like that.  To make an entry variable available, you will need to use the addFieldVariables tag on your page:
{# This line makes the entry variable available to your 
   Hidden and Invisible Field settings. #}
{% do craft.sproutForms.addFieldVariables({ entry: entry }) %}

{# After you use addFieldVariables, you can display your Form as normal #}
{{ craft.sproutForms.displayForm('contact') }}

With the code above in place, you can now use any values that you want from the entry in your Hidden or Invisible Field Settings like {{ entry.title }}, {{ entry.postDate|date('Y-m-d) }}, {{ entry.excerpt }} or even loop through an array of data like Entries or Users, just like you would in your Twig template (as long as your final value can be stored in a PlainText field.  
Dynamically access form data with Sprout Email
To send this information in a notification email, you'll first need to setup a new Notification in Sprout Email and select the rule "When a Sprout Forms entry is saved".
When your form is submitted, your Sprout Email template will have your entire SproutForms_Entry object and all of the submitted fields available to it via the object variable.
So, while your entry values were available to your form as:
{{ entry.title }}
{{ entry.postDate|date('Y-m-d) }}
{{ entry.excerpt }}

They will be available dynamically to your email template as:
{{ object.title }}
{{ object.postDate|date('Y-m-d) }}
{{ object.excerpt }}

> **Comments:**
> **username_0**: Ben thank you so much for your comprehensive answer!  
> **username_0**: Hey, I'm having trouble getting the entry variable data to the email notification. I have done the following on the entry page: `{% do craft.sproutForms.addFieldVariables({ entry: entry }) %}` followed by `{{ craft.sproutForms.displayForm('eventRsvp') }}`. The event form has a field with the handle eventTitle, so its value is `{{ entry.title }}`. Then in the template for the email I'm trying to output `{{ object.eventTitle }}` - but this just returns blank.  
> **username_1**: Dynamic values in notification templates may require single curly braces: `{object.eventTitle}`  

---

