Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
Take a look at http://cjsharp.com/blog/2013/04/11/creating-a-xform-block-in-episerver-7-mvc-with-working-validation-updated/. Although this particularly covers implementation in a block, you could also use it for page integration.
I prefer to use the latter way of rendering, since it gives me a little more control over the output of the form.
After you implement one of the methods, check the action attribute that's rendered on the form tag and see if you have a MVC action to handle it.
Which method is the preferred way of rendering a XForm in MVC?
Html.PropertyFor(m=>m.XForm,
, new { XFormParameters = new XFormParameters() { SuccessAction = "Success", FailedAction = "Failed", PostAction = "XFormPost" } })
or
@using Html.BeginXForm(Model.XForm)
Html.RenderXForm(Model.XForm,
new XFormParameters() { SuccessAction = "Success", FailedAction = "Failed", PostAction = "XFormPost" })
Second question:
When using alternative one of the above I don't get the form back after making a post in a XForm, not even reloading the page. All I get is the message you get after making a post. Anyone who knows why? I don't do anything special in the controller actions for success and failure.