@Paul George is correct when he says there is a problem with the MVC Form Rendering and it requires a DataSource
instead of a FormID Parameter.
Now this causes a big problem, because there is no way of setting DataSource to the @Html.Sitecore.Controller()
Helper Method.
The only way to solve this is by actually rendering the form with @Html.Sitecore.Rendering()
which support DataSource
.
So the code should look like this
@Html.Sitecore().Rendering("{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}", new { Datasource = "<id of the form item>"})
Where {F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}
is the ID of the Mvc Form
Controller rendering which is used for inserting forms in placeholders.
But after testing this there is actually an exception that there is no UniqueId
set for the Form, so it throws out an exception that the UniqueId
(which is required) is empty. So the actual code that should be used for rendering form in this manner is:
@Html.Sitecore().Rendering("{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}", new { Datasource = "<id of the form item>" , UniqueId = "<unique id of the form rendering>"})
I don't think there is problem setting <unique id of the form rendering>
to some value you manually choose (or generate), but I might be wrong here. I tested a couple of submissions and they passed successfully.
Still as this functionality is obviously not very tested and probably unstable, I think that the best solution for you might be to just add the form the old fashioned way, by inserting it into a placeholder.