Umbraco 7 error, when trying to render model through partial View

user3248331

I'm getting the following error when trying to render a form from a custom model in Umbraco 7.

The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'LeaveRequestStart'.

I'm using the documentation from Umbraco here to generate a form using a model, surface controller and partial view but keep receiving the above error.

here is the Model

public class LeaveRequestStart { 

    [Required]
        public String LeaveStart { get; set; }
        [Required]
        public String LeaveEnd { get; set; }
        [Required]
        public string LeaveType { get; set; }
        [Required]
        public Boolean HalfDayStart { get; set; }
        public Boolean HalfDayEnd { get; set; }



    }

Here is the partial

@model LeaveRequestStart    
    @using UmbracoWithMvc.Controllers

    @using (Html.BeginUmbracoForm("CreateLeave", "LeaveRequestSurface"))
    {
        @Html.EditorFor(x => Model)
        <input type="submit" />
    }

Any help would be greatly appreciated, i have also tried to derive my LeaveRequestStart model from RenderModel but still no love.

Aeptitude

The error is telling you here that the default rendermodel is being passed into the partial view, and it requires an instantiated LeaveRequestStart model to work / render.

In the view you're using to call this partial, how is the partial being called? In the example tutorial it shows as this;

@Html.Partial("BlogCommentForm")

How does it look within your view? It should look something like this;

@Html.Partial("PartialView", Model.LeaveRequestStart );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related