chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v2.0
143 stars 36 forks source link

Keep an eye out for CF7 to have a pre-submit trigger #885

Closed chrisblakley closed 7 years ago

chrisblakley commented 8 years ago

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).

chrisblakley commented 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

chrisblakley commented 7 years ago

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.

https://wordpress.org/plugins/contact-form-7/#developers

chrisblakley commented 7 years ago

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):

screen shot 2017-08-18 at 1 48 07 pm

chrisblakley commented 7 years ago

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).