1

I would like to set redirect URL on my forms with Sprout Forms plugin, but none of those ways work as I expect. Once I submit the form, it goes to the same page. How can I set a redirect?

1) Insert the redirect URL into "Redirect Page" field in the settings

enter image description here

The URL is not contained in the form, in HTML.

2) Put a tag of {{redirectInput}} with customHTML field

The tag is not converted to HTML <input>.

3) Put an tag with customHTML field

The input's name is automatically converted to fields[redirect].

(2) and (3) above are from this documentation; https://sprout.barrelstrengthdesign.com/docs/forms/thank-you-page.html

In addition, there are multiple forms, so I cannot write the redirect URL directly in template.

My Craft CMS is ver 3.7.57, and Sprout Forms plugin is ver 3.13.8.

2 Answers 2

2

If you are using custom templates, a good test would be to switch back to using the default templates and confirm that the redirect is working as expected. The default templates can be useful for troubleshooting as they give you a baseline to test against.

Make sure your custom templates include the Twig code that handles the hidden field for the redirect.

You can see the full template at the link above for additional context:

{%- if redirectUri is not empty %}
    {% if redirectUri|slice(0, 1)|lower == '?' %}
        {%- set redirectUri = craft.app.request.getUrl()~redirectUri %}
    {% endif %}

    <input type="hidden" aria-hidden="true" name="redirect"
        value="{{ redirectUri|hash }}">
{% endif %}
1

It appears you are using double curly braces for your redirect value where the setting only supports single curly braces for that value. You can find examples of the acceptable values in the docs and I'll post them here too:

4
  • Thank you. I changed {{SiteUrl}} to {SiteUrl}, but the issue is not fixed. As I wrote, the redirect URL is not contained in the page's source.
    – Kota.M
    Nov 28 at 14:52
  • 1
    Are you using custom templates? If so, a good test would be to switch back to using the default templates and confirm that the redirect is working as expected. I've tested the most recent version locally and redirects are working for me. The default templates output the redirect in the source here: github.com/barrelstrength/craft-sprout-forms/blob/… Nov 29 at 1:18
  • 1
    Yes, actually the template is a custom one. And the part of rendering redirect input was commented out. Now the form does the redirect to the specified URL. Thank you.
    – Kota.M
    Nov 29 at 14:57
  • Great. I've posted my comment as a separate answer for anybody else that may find themselves here. Nov 30 at 15:33

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.