e.g. something like this, maybe add a BeginChameleonForm overload that takes the model type as a shorthand too...
public static class HtmlHelperExtensions
{
public static HtmlHelper<TNewModel> ForModel<TNewModel>(this HtmlHelper html, TNewModel modelInstance = default(TNewModel))
{
var tempDataDictionary = new ViewDataDictionary(html.ViewContext.ViewData) {Model = modelInstance};
var newViewDataDictionary = new ViewDataDictionary<TNewModel>(tempDataDictionary);
var newViewContext = new ViewContext(
html.ViewContext.Controller.ControllerContext,
html.ViewContext.View,
newViewDataDictionary,
html.ViewContext.TempData,
html.ViewContext.Writer
);
var newViewData = new ViewPage<TNewModel>
{
ViewContext = newViewContext,
ViewData = newViewDataDictionary
};
newViewData.InitHelpers();
return new HtmlHelper<TNewModel>(newViewContext, newViewData);
}
}
e.g. something like this, maybe add a
BeginChameleonForm
overload that takes the model type as a shorthand too...