3

I'd like my form to return to the same page with a param ?success.

The page slug is dynamic though so will change depending on what form you are on.

/dynamic-url?success

{% set entrySlug = craft.request.lastSegment %}                         


                                    {{ craft.freeform.form("landingPage", {
                                        id: "form-landing",
                                        useRequiredAttribute: true,
                                        returnUrl: "{{ entrySlug }}?success"
                                    }).render() }}

Obviously if i just use returnUrl: "?success" it takes me back to the homepage.

The idea of this is so I can trigger facebook events upon form completion, so open to any better approaches.

Thanks

1 Answer 1

5

Have you tried using the {{ craft.request.url }} variable in your returnUrl setting?

Also you should be able to format it like so:

returnUrl: craft.request.url ~ "?success"

More details about the craft.request model can be found here: https://craftcms.com/docs/templating/craft.request

1
  • 1
    In Craft 3+ this should be craft.app.request.url otherwise you'll get a deprecation error.
    – Tim Coysh
    Commented May 9, 2021 at 12:15

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.