Creating a new custom form with it's own controller
Hello,
Hopefully someone can help me, I want to create a bespoke form but I want it to be wrapped in a template as per the other page in our CMS.While creating the form is easy enough, I want it to use its own model and it's own controller, however when I try this I get the error:-
The model item passed into the dictionary is of type
'RoundSquare.Models.MemberProfileModel', but this dictionary requires a
model item of type 'Umbraco.Web.Models.RenderModel'.
Creating a new custom form with it's own controller
Hello,
Hopefully someone can help me, I want to create a bespoke form but I want it to be wrapped in a template as per the other page in our CMS.While creating the form is easy enough, I want it to use its own model and it's own controller, however when I try this I get the error:-
The model item passed into the dictionary is of type 'RoundSquare.Models.MemberProfileModel', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.
Does anyone know how to do this?
My Template code looks like this:-
@using RoundSquare.Models;
@inherits Umbraco.Web.Mvc.UmbracoViewPage<MemberProfileModel>
@{
Layout = "Template.cshtml";
}
@{ Html.RenderPartial("~/Views/MemberProfile/MemberProfile.cshtml"); }
Thanks
Paul
Hi Paul,
In Umbraco, to use the templates and content more easily alongside MVC forms you should use Surface Controllers.
http://our.umbraco.org/documentation/Reference/Mvc/surface-controllers
Handy set of videos that give a nice intro on Umbraco TV
http://umbraco.tv/videos/developer/fundamentals/surface-controllers/the-surface-controller/
Hth
Steve
Thanks Steve, I'll have a read through now. I think i did briefly touch upon using the Surface controller, but perhaps I gave up to quickly.
I manged to sort it - going on what Steve said about Surface controllers, I managed to dig out this link which explains it well.
http://creativewebspecialist.co.uk/2013/07/22/umbraco-mvc-what-on-earth-is-a-surface-controller/
Glad you sorted it - hope you headed the warnings in the comments about keeping your logic out of the Controllers :)
is working on a reply...