We had an idea about this and came with the idea to create an extension of our own for HtmlHelper like the following:
public static class XFormsExtensions { public static MvcHtmlString ExtendedDisplayFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression) { if (!(typeof(TValue)==typeof(XForm))) throw new ArgumentException("Can only be used on XForm"); var mvcHtml = html.DisplayFor(expression); var content = mvcHtml.ToString(); return new MvcHtmlString(content.XFormToDivTransform()); } public static string XFormToDivTransform(this string content) { // Do your transformation of choice here
return content;
}
Hi
If I remember correctly the rendering of XForms in MVC is controlled by a set of editor templates. There should be one for each type of XForm fragment. The default ones can be found in the program files installation. The views are located under CMS\{versionNumber}\Application\Util\Views\Shared\EditorTemplates.
It should be possible to add overrides of those by placing custom views in the site folder ({siteRoot}\\Views\Shared\EditorTemplates). Those should have priority of the ones in program files.
Regards
Per Gunsarfs
But aren't those templates for each element in a XForm and not the XForm as a whole? What we wanted to do was to get rid of the table-elements that holds the form-elements, which the templates Per speaks of seems to render.
Ah, sorry misunderstood the original question. You are correct, those are only for the individual elements. For the wrapping thing you can use the approach that you suggested.
Regards
Per Gunsarfs
Hi,
I'm currently looking into customizing the rendering of XForms in MVC Razor (Getting rid of the table etc.), but not able to find much information on this topic. Does anyone have any information on how to accomplish this, or point me in the right direction ?
Thank you.