Closed chrisblakley closed 7 years ago
Now that Contact Form 7 uses FormData and the REST API, I wonder if we could re-visit this to not need a hidden field for Nebula data?
https://contactform7.com/2017/06/01/contact-form-7-48/#more-22829
Saw this bullet point in the 4.9 version. Could this be what I'm looking for?
Triggers wpcf7beforesubmit custom DOM event. You can manipulate the formData object through an event handler.
For reference, here is the event.detail
object that is available on submit now (this is different than above, but I wanted to reference it somewhere):
Ok this is working great now. I can remove all the debuginfo
populating lines in JS and populate it only when the form is submitted.
This still requires that the form field is created in CF7 (and needs to be present in the mail section in order to be sent in the email), but it prevents the form info from being seen in the input field on the front end. It'd still be available in dev tools in the Network for the AJAX send, but that's it.
Next thing I'd love is to be able to dynamically "create" the field so that it doesn't need to be prepped in CF7 (and no field needs to even be in the form). I don't think this is currently possible, but here's how I'd do it:
//Add another input to the inputs array
e.detail.inputs.push({
name: 'newdebuginfo',
value: nebula.session.id
});
Then [newdebuginfo]
(or whatever its called) would only need to appear in the mail settings and not the form itself).
Created a support ticket to request a trigger that allows data to be modified just before submitting via AJAX. Until then, the last timing data for browserInfo() will not appear in the email or DB.
If this is ever implemented, the browserInfo() function will only need to be called once (instead of several times throughout main.js).