An age-old question since Sitecore 9 came out is: How do I add the damn form to a page?
I am new to Sitecore Forms like most. There is a handy guide that the good people at Sitecore came up with.
Have a read, it’s pretty good but with some things missing.
I am trying to cover it here as I got it to work.
- I did not create the MVC layout.
- Instead, I created a view rendering
- Name: Form
- Path: /Views/Layouts/MVCLayout.cshtml
- Make sure you have the “Mvc Form” item in /sitecore/layout/Renderings/System/Forms/
- Created a placeholder Settings
- Name: Forms
- Allowed Controls: “Mvc Form” from above
- On your main website placeholder setting
Add “Forms” as Allowed control - Create the MvcLayout.cshtml like below
@Html.Sitecore().Placeholder("form-placeholder")
- Create MvcOuterLayout.cshtml like below
@using Sitecore.ExperienceForms.Mvc.Html @{ Layout = null; } @Html.RenderFormStyles() @Html.RenderFormScripts() @RenderBody()
- Almost there...
- Now you can Add a Form on the main placeholder
and then add a form to MVC Form Placeholder - Final page presentation should look something like
This was the only way I was able to get the validation messages to show and the form to submit
Otherwise on submit I was being redirected to
sitename/formbuilder?fxb.FormItemId=164aee8c-4c2c-4b27-9cc4-fa9e6f7dd550&fxb.HtmlPrefix=fxb.5554a312-3d4b-48f1-9ece-3b5a211b664b
What a Mess. Eh?
~ Enjoy the little things. ~