2

I am new to this so, excuse the lack of proper terminology. But I am using the Sprout Forms plugin (v1.1.0) on a site we designed for a real estate client. What I am hoping is that a visitor could fill out a form, and then the notification email would include the page title {{entry.title}} of the page which the form was filled out on. Otherwise would I need to create a unique form for every page in a craft "channel?" The site url is http://sivelluxury.com...

I've currently got this in the subject line of the notification pane for that contact form - {fullName} Submitted a contact form on {{entry}} was filled on {{ siteName }} {dateCreated|date('Y-m-d')}

Anyone who can help me?

1

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.
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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