FORMS
Form Confirmation Pages
11min
after a user submits a form and you redirect them to a confirmation page, you can now insert a dynamic message using fields from the form prerequisites you have set up a form introduction after a user submits a form, you can redirect them to a confirmation page including a form confirmation message on the page they land on allows you to develop a customisable message which can give users peace of mind that they submitted the correct information, and allow them to contact you (via a new submission) if they have made any mistakes include a nested order confirmation layout (previously only available in emails), which can give full details of any ecommerce products ordered in the form submission give a personal touch by including details like the user's name in the message refresher how to set up a redirect to a confirmation page step 1) create a page in the siteglide admin under cms > pages this will serve as your confirmation page step 2) edit your form in the siteglide admin under cms > forms step 3) fill in the ``redirect to`` field with the url of your confirmation page including the confirmation message in the siteglide admin under cms > pages in the page builder tab, add the confirmation message using the following liquid {% include 'form confirmation', layout 'default' %} the layout parameter takes the name of the layout file you wish to use, without the liquid extension form confirmation layouts file structure we store form confirmation layouts at the following path layouts/form confirmation/ each layout should be a single liquid file with a name of your choice followed by liquid developing a layout you can use the default layout, or develop your own variables when setting up this feature, we wanted to make sure you could easily keep layouts consistent between the on page and email success messages in an email notification you have access to the "form" variable, containing details of the fields that were submitted in the form in the form confirmation layout, we've given you access to this {{form properties}} variable in the same format, as well as the usual this variable you may be more familiar with in other layouts you can either copy and paste your layout from an email notification over to the form confirmation layout and continue to use {{form properties}} , or use the {{this}} object as you may be used to in other layouts note you will not currently be able to use the {{this}} variable inside an email notification if you want to keep the same layout, stick to the {{form}} variable! using {{this}} thanks for getting in touch! nice to meet you {{this name}}! we'll get back to your query as soon as possible using {{form properites}} in a layout copied from an email notification thanks for getting in touch! nice to meet you {{form properties name}}! we'll get back to your query as soon as possible outputting fields dynamically you can choose to re use the same confirmation message for multiple forms here is an example which will list the submitted fields (whatever they may be!) in an html table be aware, depending on the form, it may always need some adjustments to cover more unusual field types e g checkboxes in the meantime, please double check the information you provided us below {% for field in this %} {% comment %}use the following unless condition to list fields you'd like to leave out of the message {% endcomment %} {% unless field\[0] == "properties" or field\[0] == "user id" or field\[1] == blank %} {{field\[0]}}{{field\[1]}} {% endunless %} {% endfor %} if you're interested to read more about using liquid to loop over the properties of an object, as we've done in this example, see more in this advanced tutorial advanced arrays and key maps tutorial docid 98it82fannzrnuf8t wkh including an ecommerce order confirmation as in an email notification, you output details about any ecommerce order that was made with the form submission we've included an {% if %} statement in the example, because this will only work properly if aform properties order id field is available on the page, otherwise it may be that the form was submitted without the user making an order {% if form properties order id %} {% include "ecommerce/order details", layout "siteglide example" %} {% else %} looks like you've not ordered anything with us this time we hope to see you again soon! {% endif %} how to make sure the confirmation message is only displayed once the form confirmation feature will continue to show details of the most recent form submission if the feature is added to a page that will have visitors who have not just submitted a form, this may no longer be relevant to prevent confusion, you can choose to clear the form data from their session so that once the message has been read, it won't display again we store two values "form id" and "form fc" within {{context session}} , which are then used to check whether the form confirmation layout should be inlcuded if we wipe these values the first time "form confirmation" is included then the layout won't be included again, this code should be added to your form confirmation layout {% session form id = null %} {% session form fc = null %}