Copied to clipboard

Flag this post as spam?

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


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

    Loading form scripts in forms v7.x.x

    Hi, Have anyone figured out how to load scripts before </body> in Forms v7? I'm calling the macro InsertUmbracoFormWithTheme manually in my template, where I set ExcludeScripts = "0", which prevents the code in Scripts.cshml in my theme from running. So far so good.

    What I haven't figured out, is how I can control where to render the scripts. In the previous version, you could just follow this from the documentation https://our.umbraco.org/documentation/Add-ons/UmbracoForms/Developer/Rendering-Scripts/ .

    You can still do this in v7, if you create the macro in Umbraco, and point it to the macro partial called RenderUmbracoFormScripts.cshtml. But this will load the old scripts, which are still present for some reason.

    What I'd like, is a way to run the code in Scripts.cshtml in my theme folder at a point of my selection. Essentially the code in Scripts.cshtml loads the script files in App_Plugins/UmbracoForms/Assets/themes/your-theme instead of the old script files located in App_Plugins/UmbracoForms/Assets/.

    However, I noticed that when I insert the InsertUmbracoFormWithTheme macro in an RTE, everything works perfectly 🤔

    Anyone had succes with this? Thanks!

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jun 03, 2018 @ 18:06
    Chriztian Steinmeier
    101

    Hi OleP,

    Yes - it's not easy - and part of the reason is that the docs are a little confusing now that there are two versions.

    You need to look at the bottom of the "Themes" docs for a hint to this: https://our.umbraco.org/documentation/Add-ons/UmbracoForms/Developer/Themes/#rendering-script-content-separately

    I've wasted several hours trying to do this and then having my changes overwritten by an UmbracoForms upgrade on Cloud...

    Make sure to create your own theme files instead of modifying the built-in ones (macro partials and views).

    Hope that helps,

    /Chriztian

  • OleP 67 posts 276 karma points
    Jun 03, 2018 @ 20:06
    OleP
    1

    THANK YOU!

    I feel stupid for spending so many hours trying to set this up correctly, and then the answer is so simple and RIGHT THERE!

Please Sign in or register to post replies

Write your reply to:

Draft