• Resolved Niels Pilon

    (@nielspilon)


    Hi,

    I’m running into an issue where Javascript is added above a selected form with encoded characters. This causes an error and prevents forms from being submitted.

    The Javascript added is this line

    <script type="text/javascript">if(!gform){document.addEventListener("gform_main_scripts_loaded",function(){gform.scriptsLoaded=!0}),window.addEventListener("DOMContentLoaded",function(){gform.domLoaded=!0});var gform={domLoaded:!1,scriptsLoaded:!1,initializeOnLoaded:function(o){gform.domLoaded&&gform.scriptsLoaded?o():!gform.domLoaded&&gform.scriptsLoaded?window.addEventListener("DOMContentLoaded",o):document.addEventListener("gform_main_scripts_loaded",o)},hooks:{action:{},filter:{}},addAction:function(o,n,r,t){gform.addHook("action",o,n,r,t)},addFilter:function(o,n,r,t){gform.addHook("filter",o,n,r,t)},doAction:function(o){gform.doHook("action",o,arguments)},applyFilters:function(o){return gform.doHook("filter",o,arguments)},removeAction:function(o,n){gform.removeHook("action",o,n)},removeFilter:function(o,n,r){gform.removeHook("filter",o,n,r)},addHook:function(o,n,r,t,i){null==gform.hooks[o][n]&&(gform.hooks[o][n]=[]);var e=gform.hooks[o][n];null==i&&(i=n+"_"+e.length),null==t&&(t=10),gform.hooks[o][n].push({tag:i,callable:r,priority:t})},doHook:function(o,n,r){if(r=Array.prototype.slice.call(r,1),null!=gform.hooks[o][n]){var t,i=gform.hooks[o][n];i.sort(function(o,n){return o.priority-n.priority});for(var e=0;e<i.length;e++)"function"!=typeof(t=i[e].callable)&&(t=window[t]),"action"==o?t.apply(null,r):r[0]=t.apply(null,r)}if("filter"==o)return r[0]},removeHook:function(o,n,r,t){if(null!=gform.hooks[o][n])for(var i=gform.hooks[o][n],e=i.length-1;0<=e;e--)null!=t&&t!=i[e].tag||null!=r&&r!=i[e].priority||i.splice(e,1)}}}</script>

    This script is only added when the form is selected with the GF relationship field. When embedding the form with the native GF Gutenberg block the form works without any issues and no Javascript is added above the form.

    This happens for any selected form. It doesn’t matted if the output is the relationship field is an object of just the ID.

    I can’t think of any reason why this happens. I’ve also reported this issue to GravityForms as I’m not sure if it’s caused by GF or this plugin.

    Any help is much appreciated.

    Kind regards,
    Niels

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    This plugin doesn’t add any code to the frontend of the website. It only adds a custom selection field to the Field Group view in WordPress Admin. Please let us know what response you receive from Gravity Forms.

    Thread Starter Niels Pilon

    (@nielspilon)

    Hi Mark,

    Thanks for your swift reply. I thought so too but just asked the question here to be sure.

    I did check similar code on another site when using the ralationship field and above the gform_wrapper an empty line of Javascript like <script type="text/javascript"></script> was added as well for some reason.

    I will update this ticked once I’ve got a reply from Gravity Forms 🙂

    Thread Starter Niels Pilon

    (@nielspilon)

    Hi Mark,

    Contacted Gravity Forms and did some further debugging. It seems like it has something to do with ACF and not Gravity Forms or your plugin.

    This issue only happens when I’m using a custom Gutenberg block made with ACF which uses the gravity_forms function to render a form.

    It happens in a clean WP install too with the default theme and GF and ACF as only installed plugins.

    I will contact ACF support to see if they know about this issue.

    Kind regards,
    Niels

    Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    Thanks for letting us know!

    @nielspilon dit you manage to fix this? I encounter the same problem, any way to fix this? Thanks!

    • This reply was modified 2 years, 6 months ago by pamamo.
    Thread Starter Niels Pilon

    (@nielspilon)

    @pamamo Yes I did and it wasn’t anything plugin related.

    What happened is that we have security headers enabled. One of these setting was X-Frame-Options set to DENY. After changing it to SAMEORIGIN the errors are all gone.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘JS added above form with encoded characters’ is closed to new replies.