Forms feature is a new and awesome piece of Sitecore 9. However, there are some common practices most developers get used to, so I’m going to cover a few scenarios of implementing forms.
One of the most common scenarios is thank you message after visitor has submitted your form. With non-ajax case it’s pretty easy, you just redirect user to the thank you page. But what if you are doing ajax form and want to show thank you message after successful submission of the form? Apparently, that’s simply achievable with the Sitecore Form Page. Here is a small guide how you can do that:
Got to Sitecore Dashboard and then to Forms
On the form editor navigate to Form Elements panel and find Structure accordion. There you have “Page” element. Drag-and-drop 2 pages to your form. So the first page is going to be your form with submit button, and the second one will display our thank you message.
Add submit button to the first page and don’t forget to specify submit actions (don’t add a redirect in submit actions). Select “Next” for the Navigation step field.
Add “Text” component to the second page and write a thank you message.
Navigate to the Settings tab and set “AJAX enabled” checkbox. Save the form, and voila. Now when you click on the submit button, you’ll see thank you message.
Please don’t forget that you need to have Sitecore 9 Forms scripts and styles loaded on your page. You can do it with:
@Html.RenderFormStyles() //inside head tag @Html.RenderFormScripts() //before closing body tag.
Apiqu latest updates and industry developments.