Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mohammed 17 posts 88 karma points
    Feb 19, 2015 @ 07:21
    mohammed
    0

    Create a document type for forms

    Hi,

     

    I am new to Umbraco and I want to create a document type for forms in Umbraco and I am having issues. I want to create a reusable document type for all the forms. At the moment, I created a FormType document type and I am creating partial views for all my forms and then placing macros in the forms that create from. However, I am now getting an error that the form cannot be rendered. Can someone please help me with the best practice for creating a reusable document type for all my forms?

     

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 19, 2015 @ 08:05
    Jan Skovgaard
    0

    Hi Mohammed and welcome to our :)

    What does the error you're getting specifically say? And could you perhaps post some screendumps that displays what you're doing? Just want to make sure I get what you're up to.

    /Jan

  • mohammed 17 posts 88 karma points
    Feb 19, 2015 @ 08:13
    mohammed
    0

    Sorry, my explanation was confusing. On the FormType document type, I created a property called content. So when I create any page from that document type, I put in the macro that contains the form partial view. Now on the front end, I just get an error saying "Error loading partial view XXXX.cshtml". No specific error about why the view is breaking and cannot load. Even the console in the browser is blank. So my question is more about, is this a good way to create forms or can someone suggest a better way so that I can create one document type and multiple forms from that document type in Umbraco.

     

    Thanks for your help

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 19, 2015 @ 08:18
    Jan Skovgaard
    0

    Hi Mohammed

    Ok, could you try having a look in the /App_Data/Logs file? It should contain a stack trace about the error somewhere. Please post that in here :)

    /Jan

  • mohammed 17 posts 88 karma points
    Feb 19, 2015 @ 08:26
    mohammed
    0

    Hi,

    Sorry, its on my other machine, will post it as soon as I get home.

    Thanks Jan

  • mohammed 17 posts 88 karma points
    Feb 19, 2015 @ 17:56
    mohammed
    0

    Hi,

     

    Here is the Stacktrace from the log file:

    015-02-18 19:14:37,784 [9] WARN  umbraco.macro - [Thread 11] Error loading partial view macro (View: ~/Views/MacroPartials/Register.cshtml). Exception: System.InvalidOperationException: The model item passed into the dictionary is of type 'Umbraco.Web.Models.PartialViewMacroModel', but this dictionary requires a model item of type 'MVCUmbracoFreelance.Models.Register'.
       at System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value)
       at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary)
       at System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData)
       at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
       at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
       at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
       at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)
       at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content)
       at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, INode node)
       at umbraco.macro.LoadPartialViewMacro(MacroModel macro)
       at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

     

    I have seen this error before I know how to resolve it in a normal scenario but in this case I created a document type called "FormType". In the document type, I creaed a property called Content of type Richtext Editor. In this field I insert a macro above. This is where I am getting this error. Is there a way I can pass in the model or is there a better way to do this?

     

    Thank you

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 19, 2015 @ 18:00
    Jan Skovgaard
    0

    Hi Mohammed

    Ok, what does your macro code look like? You probably just need to inherit the model in the macro I guess.

    /Jan

  • mohammed 17 posts 88 karma points
    Feb 19, 2015 @ 18:29
    mohammed
    0

    Hi Jan

    My partial view looks like:

    @model MVCUmbracoFreelance.Models.RegisterFreelancer

     

    @using (Html.BeginUmbracoFormAccountSurfaceController>("Register", null, new { @id = "registerform", @class = "form-gray-fields validate" }, FormMethod.Post))

    {

    }

     

    In Umbraco, I create a macro and use this partial view above.


    Thanks Jan

  • mohammed 17 posts 88 karma points
    Feb 19, 2015 @ 19:08
    mohammed
    101

    Hi Jan,

    I managed to resolve the issue by changing the code a little. I found this article that helped: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/57275-Partial-Macro-View-issue-(Custom-Model-and-RenderModel)

    Thanks a lot for your help. I will definitely post again if I come across any other issues.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 20, 2015 @ 08:35
    Jan Skovgaard
    0

    Hi Mohammed

    Aaah, good you managed to figure it out and thanks for sharing so it's easy for others to figure out what worked for you if they have the same issue. You should mark your last post as the solution so others can go straight to it :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft