Try our conversational search powered by Generative AI!

MVC XForm troubles

Vote:
 

I'm experimenting a bit with XForms, both on a page, and in a block.

So far I have managed to get the postings to work from both, by a bit of trickery, but for some reason, the default rendering of the action attribute does not include the current language branch, so all postings go to the master language version. Am I missing something? I'd rather not start writing a workaround, if there'se nothing to work around :)

 

#65736
Feb 07, 2013 9:49
Vote:
 

Probably pretty late reply. But anyway for reference:

I found it useful to write form action Url to the view model in controller (for instance):

var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var pageUrl = urlResolver.GetVirtualPath(currentPage.ContentLink);
 
var actionUrl = string.Format("{0}XFormPost/", pageUrl);
actionUrl = UriSupport.AddQueryString(actionUrl, "XFormId", viewModel.Form.Id.ToString());
actionUrl = UriSupport.AddQueryString(actionUrl, "failedAction", "Failed");
actionUrl = UriSupport.AddQueryString(actionUrl, "successAction", "Success");
 
viewModel.ActionUrl = actionUrl;

    

And then write XForm using BeginXForm method:

@using (Html.BeginXForm(Model.Form, new { Action = Model.ActionUrl }))
{
    Html.RenderXForm(Model.Form);
} 

    

 

More info about how to host in blocks: http://blog.nansen.com/2013/03/creating-xform-block-in-episerver-7-mvc.html

#74125
Aug 21, 2013 10:02
Vote:
 

There's a slightly updated version of the above mentioned blog post here: http://cjsharp.com/blog/2013/04/11/creating-a-xform-block-in-episerver-7-mvc-with-working-validation-updated/

#74171
Aug 21, 2013 17:48
Vote:
 

Ah, good to know :)

#74177
Aug 21, 2013 21:16
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.