7

We have started migrating from WFFM to Experience Forms on Sitecore 9.0.1. I've hit an issue with jQuery reference clashes and would like to know the best way to solve it.

I started by following the instructions on this page: https://doc.sitecore.com/developers/90/sitecore-experience-management/en/add-a-form-to-a-webpage.html . I didn't create the MVC layout or MVC outer layout as we want to drop forms into existing layouts. We do not want to create and use a new layout just for forms. I did add calls to @Html.RenderFormStyles() and @Html.RenderFormScripts() to our existing layouts.

Our existing layouts include references to jQuery, jQuery.validate and jQuery.validate.unobtrusive. These scripts are included again when @Html.RenderFormScripts() is called on the page. Some of these scripts are different versions. For example, We are using jQuery 2.2.0 and Sitecore forms is using jQuery 2.1.3. I've found that script errors are thrown when these libraries are included more than once.

Some potential solutions I've investigated are:

  1. Changing the "Scripts" field on a form so it excludes scripts that would be duplicated. The drawback for this solution is content editors will need to make this change for every form they create
  2. Change the standard values for /sitecore/templates/System/Forms/Form so it excludes duplicate scripts. This doesn't seem ideal either as we'd have to sync a system template item into our solution (we use TDS)
  3. Instead of calling @Html.RenderFormScripts(), manually include references to the JS files we need from /sitecore%20modules/Web/ExperienceForms/scripts/ . This feels more like a workaround than a proper solution

Has anyone found a nice way to handle these duplicate jQuery references?

Thanks

  • We also faced same issue while migrating to Sitecore 9 update 1 and We have followed the third option - remove the @Html.RenderFormScripts() and add the required scripts references. – Hussain Dec 19 '18 at 8:07
1

A Form item gets created as soon as you save the form. The Form templates standard values items have this:

See this

You can update this, but this would be changing the Sitecore's Form template. I am sure Sitecore would control the version of the Javascript files when they upgrade Sitecore version.

Not a great answer. Just another approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.