I'm looking to redirect the user to the same page that they were on, with an additional query string.

Is this possible?

Thanks Adam

up vote 2 down vote accepted

Sprout Forms now supports relative redirects.

Example redirect values:

We've also added this info in the documentation

Sure, in the control panel for sprout forms you can set the redirect page. Say the url for your contact page is /contact you can do something like redirect to:

contact?message=thank-you

and then in your contact template do something like:

{# Check if we should display a thank you message #}
{% if craft.request.getParam('message') == 'thank-you' %}
 //do stuff here
{% endif %}

Sprout installs a bunch of sample forms, there's plenty to gleam and learn from these.

  • Thanks for your response, erwinheiser. What if the URL is a specific entry, rather than a contact page where the URL is known? I am using the form on many pages, and would like to redirect to the same page. I envisage that if not possible with Craft Sprout Forms, I may just have to use javascript when the page loads to alter the contact of the redirect data-attribute. – Adam Menczykowski Nov 23 '15 at 11:54
  • if you're always redirecting to the same page then set that page as your redirect url. Should work. – erwinheiser Nov 23 '15 at 20:58
  • The problem is that I don't know the url, as the same form is on many pages, and I want to return to the page the form is on but with an additional query string e.g. If the form is on example.com/page1 then I want to redirect to example.com/page1?status=thankyou. And if I am on example.com/page2 then I want to redirect to example.com/page2?status=thankyou – Adam Menczykowski Nov 25 '15 at 15:22
  • hmmm, I see, not sure if that's possible. Maybe check in with Ben at Sprout for a feature request? – erwinheiser Nov 25 '15 at 20:43
  • OK Thanks a lot for your help, I will contact Sprout directly. – Adam Menczykowski Nov 26 '15 at 21:25

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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