This is now possible with Sprout Forms 2.0 and Sprout Fields 1.0 Hidden or Invisible Field.
You'll need to make your entry available to the Hidden of Invisible field using the addFieldVariables
tag, and then in your field settings you can reference the Entry ID using single curly braces: {entry.id}
{# Make the Entry available to your Hidden or Invisible field settings #}
{% do craft.sproutForms.addFieldVariables({ entry: entry }) %}
{# Output your form as normal #}
{{ craft.sproutForms.displayForm('contact') }}
See Setting a dynamic value (outside the global scope).
Legacy Answer (pre Sprout Forms 2.0)
When a form is submitted, the form notification has access to the variables in the SproutForms_EntryModel
which include all the custom fields submitted with the form and anything in the global scope such as {{ currentUser.email }}
.
To make the Subject Line of the page that the form was submitted from available to your notification, you will need to make it a field on your form.
This may be a little tricky to do with dynamic forms right now, but we are working on a way to make this easier in the future using a Hidden Field field type.
A couple approaches to consider right now:
- Write a Hidden Field custom field type that behaves like you need it to
- Build your form with custom HTML and populate a hidden field on your form with the
{{ entry.title }}
value.
- Create a "Page Title" Plain Text field on your form, style it to
display:none
so the user never sees the field there, and populate the field with the entry title using javascript.