I am having trouble getting a freeform success message to display. I am posting back to the same template. What is the proper way to check if the form was posted? I see in the freeform render template there is a freeform.hasErrors, is there something for success perhaps?
{% if craft.request.getPost('firstName')|length %}
<div class="callout success">Your message has been sent.</div>
{% else %}
{{ craft.freeform.form("contactForm", {
formAttributes: { "data-abide": true },
instructionsBelowField: true,
submitClass: "button",
returnUrl: "/contact",
useRequiredAttribute: true
}
).render() }}
{% endif %}
https://solspace.com/craft/freeform/docs
Update: Working code using query param instead. Thanks @Jan_dh.
{% if craft.request.getQuery('success') == 1 %}
<div class="callout success">Your message has been sent.</div>
{% endif %}
{{ craft.freeform.form("contactForm", {
formAttributes: { "data-abide": true },
instructionsBelowField: true,
submitClass: "button",
returnUrl: "/contact?success=1",
useRequiredAttribute: true
}
).render() }}
{% endif %}