Copied to clipboard

Flag this post as spam?

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


  • Myles Broomes 3 posts 73 karma points
    Nov 22, 2017 @ 16:35
    Myles Broomes
    0

    Forms Scripts Macro not rendering scripts

    Hello all,

    I'm trying to render form scripts using the following:

    @Umbraco.RenderMacro("FormsRenderScripts")
    

    ...but for some reason all that's being outputted is:

    <Macro:  (,)>
    

    Any reason why this might be happening? I've followed the documentation (https://our.umbraco.org/documentation/Add-ons/umbracoforms/developer/rendering-scripts/) to a tee and also scoured the forums but still can't get it to work :/ Thanks in advance.

  • Pedro Mendes 53 posts 258 karma points
    Jan 11, 2018 @ 22:42
    Pedro Mendes
    1

    Hey there Myles,

    Don't know if you're still experience this issue but that happens because that macro - FormsRenderScripts - doesn't exist.

    I believe the docs are a little bit outdated, but still, here is my solution:

    1. Create a new Macro called, for example, "Forms Render Scripts" that uses the RenderUmbracoFormScripts view "~/Views/MacroPartials/RenderUmbracoFormScripts.cshtml"

    2. In the file ~/Views/MacroPartials/InsertUmbracoFormWithTheme.cshtml update line 47 from

    Html.RenderAction("RenderForm", "UmbracoForms", new {formId = form, recordId = recordGuid, theme = theme, includeScripts = includeScripts });
    

    to

    Html.RenderAction("RenderForm", "UmbracoForms", new {formId = form, recordId = recordGuid, theme = theme, includeScripts = includeScripts, mode = "forms" });
    

    3. In the template where you are calling all your other scripts, add

    @Umbraco.RenderMacro("FormsRenderScripts")
    

    4. Remove any umbracoForms.js and other scripts calls from your theme's Script.cshtml

    And that's about it.

    As a side note, I've updated my jQuery Validate and jQuery Validate Unobtrusive to the latest version, so I could use my jQuery v3 and it's all working fine - apparently at least :)

  • Chris Morley 12 posts 103 karma points
    Jan 15, 2018 @ 11:45
    Chris Morley
    0

    Thanks for this Predo

    I was having the exact issue described above i couldn't figure out how to integrate the differences in the latest version (7.6.11) to the version documented. It was the creation of the new macro referencing the existing Render UmbracoForm Scripts which was the missing part for me

    Thanks

  • Walter Kjell Dahl 6 posts 58 karma points
    Mar 14, 2018 @ 11:37
    Walter Kjell Dahl
    0

    Thanks! This solved it for me too!

  • OleP 67 posts 276 karma points
    Jun 03, 2018 @ 14:44
    OleP
    0

    @Pedro Mendes When I follow this the form and form validation works, but my conditions doesn't apply. Do conditions work for you?

    Seems like the macro RenderUmbracoFormScripts.cshtml loads a different set of script files, that looks to be deprecated.

    If I insert a form using the InsertUmbracoFormWithTheme macro in a RTE, everything works perfect. However, if I call the macro manually from my template, I get the jQuery has not been loaded & is required for Umbraco Forms error, because I load my scripts before the body tag ends.

    But why does it work with the macro in a RTE? 🤔

  • Pedro Mendes 53 posts 258 karma points
    Jun 06, 2018 @ 15:06
    Pedro Mendes
    0

    Hey there OleP,

    I've not tried conditions with the validation... I'll try to reproduce it and will get back to you when I'm able to :)

    If you, eventually, figure this out, please share it :D

  • OleP 67 posts 276 karma points
    Jun 07, 2018 @ 07:05
    OleP
    0

    There's a section in the themes documentation on how to set it up properly: https://our.umbraco.com/documentation/Add-ons/UmbracoForms/Developer/Rendering-Scripts/

    The docs are a bit confusing at the moment, since obsolete documentation is still present, like the one OP linked to.

    EDIT: Documentation is now up to date

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Jun 06, 2018 @ 14:59
    Steve Morgan
    0

    Hi,

    I've just had these issues, it's on a project I've inherited so no idea what the steps are to reproduce but it's with the DocTypeEditor, changing it so the scripts are output at the end and using a theme.

    The above steps helped but the conditional logic on certain fields still didn't fire.

    After following the fix in http://issues.umbraco.org/issue/CON-1463 to fix the radio box conditional issue I then found it still wasn't firing... I debugged it to this line:

    var form = $('#umbraco_form_' + formId + ' .umbraco-forms-page');
    

    In the Script.cshtml file - removing the .umbraco-forms-page class section meant it then found my form and started firing conditionals.

    var form = $('#umbraco_form_' + formId);
    

    I hope this helps someone else's sanity. I'd report the bug but I've no idea where to start. Has there just been a refactor of Umbraco Forms - this is pretty buggy stuff.

    Steve

  • Michael Argentini 20 posts 130 karma points
    Jul 25, 2019 @ 19:15
    Michael Argentini
    2

    Here's how I solved it with Umbraco Forms 8.1.1. Just specify that exclude scripts should be false:

    @Umbraco.RenderMacro("renderUmbracoForm", new { FormGuid = Model.Value("form"), FormTheme = "Default", ExcludeScripts = "0" })
    
Please Sign in or register to post replies

Write your reply to:

Draft