Ad

Shopify Liquid: How Does "form.posted_successfully?" Work?

- 1 answer

I was reading this page and came across this code:

    {% if form.posted_successfully? %}
      <p class="quote">{{ 'contact.form.post_success' | t }}</p>
    {% endif %}

What I don't understand is, as a server-side language, how does liquid know whether the form is submitted successfully or not?

Ad

Answer

There is a GET attribute that is applied to the page URL that is set to true if the form is successfully submitted ->?contact_posted=true.

If that GET attribute is present in the URL address the if statement becomes true and it will show the success message.

Ad
source: stackoverflow.com
Ad