Copied to clipboard

Flag this post as spam?

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


  • Bendik Engebretsen 105 posts 202 karma points
    Aug 19, 2015 @ 08:32
    Bendik Engebretsen
    0

    Adding a form

    I have tried to follow the series of videos on Umbraco.tv about Umbraco forms. I'm currently on Version 7.2.8, and using the Fanoe starter kit.

    Everything seemed fine until I actually inserted a form on a content page. The site now chokes in Visual Studio with a couple of exceptions:

    The first one is an HttpCompileException at line 140 in \Views\Partials\Forms\Form.cshtml

    @Html.Partial(FormViewResolver.GetScriptView(Model.FormId), Model)
    

    and the second one is an HttpException at line 8 in \Views\MacroPartials\RenderUmbracoFormScripts.cshtml

    Html.RenderAction("Render", "UmbracoForms", new { formId = form, mode = "script"});
    

    What I have found to be the offending code (I might be wrong) is this line at the bottom of my Master template:

    @Umbraco.RenderMacro("FormsRenderScripts")
    

    which was inserted during the fourth video "Preparing your frontend". I have also noticed that inserting this with the Insert Macro function (button) in 7.2.8 does not insert identical code to that in the video. In the video, the line looks like this:

    @Umbraco.RenderMacro("umbracoforms.RenderScripts")
    

    And if I change the code to this, the exceptions go away. However, I am now seeing some strange markup rendered at the bottom of the page:

    Any ideas on what I am doing wrong?

  • Craig Cronin 304 posts 503 karma points
    Aug 19, 2015 @ 08:59
    Craig Cronin
    0

    Have you tried

    @Html.Action("Render", "UmbracoForms", new { formId = form, mode = "script" });

    Obviously it all depends on your parameters names etc?

    This assumes you have a controller called "UmbracoForms" that has an action "Render" and accepts two parameters.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 19, 2015 @ 09:01
    Dennis Aaen
    0

    Hi Bendik,

    What if you are adding the form with something like this:

    @Umbraco.RenderMacro("FormsRenderForm", new {FormGuid="939c2061-32a1-4e99-92e1-f38931e033f0"})
    

    Will this work? Remember to change the GUID of the form, so it match yours.

    You can find the GUID in the url, when you are on the form in the Umbraco backoffice.

    Hope this helps,

    /Dennis

  • Bendik Engebretsen 105 posts 202 karma points
    Aug 19, 2015 @ 11:53
    Bendik Engebretsen
    0

    Hi Dennis,

    Well, that is how it is coded in the actual document template where the form is. This code is inserted automatically with the Insert Macro function (button) in the backend, as shown in the video "Adding forms to your templates". Allthough, there is also a slight difference in the code from the video, but I guess that has something to do with version. And the form seems to work fine, actually:-) (It gives me an error when trying to send an e-mail as part of the workflow, but that's probably my setup and local hosting.)

    However, in the previous video "Preparing your frontend", one inserts an other macro at the bottom of the Master template, and this is what causes the problem in question.

    But maybe this just isn't needed anymore in the new version? (As I said, the form appears to work.)

    Bendik

  • Craig Cronin 304 posts 503 karma points
    Aug 19, 2015 @ 11:55
    Craig Cronin
    0

    sorry Bendik,

    I misread your email while working on something else....oppppsss!!!!

Please Sign in or register to post replies

Write your reply to:

Draft