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, 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!

1 Answer 1


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 }}
  • Ben thank you so much for your comprehensive answer! Nov 17, 2015 at 8:50
  • 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. Nov 17, 2015 at 16:40
  • Dynamic values in notification templates may require single curly braces: {object.eventTitle} Nov 18, 2015 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.