Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    May 19, 2014 @ 12:07
    Bo Damgaard Mortensen
    0

    Render different view depending on form guid

    Hi all,

    I need to render a different form view for a specific form in Contour. Using Umbraco v. 7.1.2 and Contour v. 3.0.21.

    In Form.cshtml, I have a simple if statement checking if the form GUID is equal to the form I need rendered differently.

    Snippet from Form.cshtml:

    @if (Model.FormId.Equals(new Guid("831e7420-5d1f-4c71-8278-e62b46ba9a2f")))
    {
        @Html.Partial("~/Umbraco/Plugins/umbracoContour/Views/NewsletterForm.cshtml", Model)
    }
    else
    {
        // Render the normal form view
    }
    

    The newsletter form renders just fine, but when I click the submit button it gives me this:

    Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
    

    I've debugged the code and the exception seems to happen in this call:

    @Html.RenderMvcAction(action, controller, formGuid, formtoken, (umbraco.MacroEngines.DynamicNode)Model, (System.Dynamic.DynamicObject)Parameter);
    

    in MvcRenderContourForm.cshtml

    I'm just not sure what collection is empty :-)

    Is this the "right" approach to render forms with a difference view?

    Thanks in advance!

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 19, 2014 @ 12:33
  • Comment author was deleted

    May 19, 2014 @ 12:37

    You can have specific views for a single form, check documentation here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Custom-Markup/ :)

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    May 19, 2014 @ 12:46
    Bo Damgaard Mortensen
    1

    Thanks guys, learned something new there :-)

    I've simply created a new folder with the newsletter form guid, copied the original Form.cshtml to it and modified it and everything works as it should now.

    Thanks again!

Please Sign in or register to post replies

Write your reply to:

Draft