Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter pche32

    (@pche32)

    Erik you are GOLDEN!
    thank you very much,

    since i fixed what you directed me to, it wasn’t even necessary change the way i registered javascript (so i left it using: wp_enqueue_script)

    i’m posting code if anyone would be looking for something similar:

    
    const wpcf7Forms = document.querySelectorAll('.wpcf7');
    if (wpcf7Forms.length) {
      for (const wpcf7Form of wpcf7Forms) {
                
        const formElem = $(wpcf7Form)[0].querySelector('form');
        let formData = new FormData(formElem.formData);
    
        function getArr() {
          //your logic here
          return arr;
        }
    
        formElem.addEventListener('formdata', (e) => {
          var arr = [];
          arr = getArr();
          e.formData.append('custom-input', JSON.stringify(arr));
          formData = e.formData;
        });
    
      }
    }
    
    • This reply was modified 4 years, 10 months ago by pche32.
    Thread Starter pche32

    (@pche32)

    Hi Erik,

    thank you very much for pointing me to the right direction,
    if you don’t mind i would like to ask you additional/related question:

    since i prefer not to modify plugin’s script.js itself what is ideal place to hook my js (script in dedicated file) itself ?

    and so if i understand it correctly, final code should look like this:

    
    const formElem = $(wpcf7Form)[0].querySelector('form');
    let formData = new FormData(formElem.formData);
    
    formElem.addEventListener('formdata', (e) => {
        e.formData.append('custom-input-field', JSON.stringify(arr));
        formData = e.formData;
    });
    

    thank you very much for your support and patience

    Thread Starter pche32

    (@pche32)

    hello @ahmedkaludi,
    because of this and other errors we decide to disable it for now,

    if you need any input regarding this error i reported, just let me know (what kind of data and how to gather them)

    Regards
    R

Viewing 3 replies - 1 through 3 (of 3 total)