This document is for an older version of

Freeform

.

View latest version →

Returning Submit to Same Page

Aside from the obvious of using AJAX, you can achieve this by adding a query in the success URL instead of an additional segment, etc.

 
 
 


 






{% if craft.app.request.getQueryParam('success') == 1 %}
  <div class="callout success">Your message has been sent.</div>
{% endif %}

  {{ craft.freeform.form("contactForm", {
      returnUrl: "/contact?success=1",
      submitClass: "button",
    }
  ).render() }}

{% endif %}
1
2
3
4
5
6
7
8
9
10
11

Or a different option, simply redirecting to /contact?success:

{% set successParam = craft.app.request.getParam('success') %}
{% if successParam is not null %}
  <p>Success!!</p>
{% endif %}
1
2
3
4

And in case you're looking for a dynamic way of setting a return URL with combining several segments:

{% set returnUrlPath = siteUrl ~ "get-quote/" ~ craft.app.request.getSegment(2) ~ "?success=1" %}
1