• Resolved Drunkard100

    (@drunkard100)


    Hey there,

    I’m using a plugin to insert dynamic fields into contact form 7. It works great with the plugin, allowing me to add user information to the contact forms so that users don’t have to re-enter their contact information in the form.

    Anyway, the issue is that the fields refresh right along with the other fields on submit. I do not want this information to refresh along with the rest of the fields, in case they need to submit multiple times without refreshing the browser (which one group will need to do). They use the form to post project updates, for multiple projects.

    I need to know where to edit the contact form 7 plugin so that I can stop these fields from refreshing with the others.

    Thanks in advance ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Drunkard100

    (@drunkard100)

    Would ajaxSubmit help with this issue? I’ve noticed a little documentation within the jquery.form.js file of the plugin that speaks about it, but little is mentioned on how to use it.

    Any ideas or a point in the right direction would be greatly appreciated. ??

    Hi Drunkard100,
    did you have any luck with this? I have the exact same question. Did you have any success finding a solution?
    thanks
    Matt

    I have a solution which suits my purposes. Perhaps this will also suffice for anyone else seeking a similar workaround.
    In the contact-form-7 plugin directory, open scripts.js in your text-editor of choice and comment out the line which clears the form as per the code below:

    if (1 == data.mailSent) {
    //$(data.into).find('form').resetForm().clearForm();
    ro.addClass('wpcf7-mail-sent-ok');

    I suppose ideally, this would be able to be set on a field by field basis in the contact form html, but the above solution works for what I need.

    Thread Starter Drunkard100

    (@drunkard100)

    Hi mamikel,

    Actually, yes. Sorry, I have been really busy lately. Here’s a quick solution that keeps the dynamic fields as is, while clearing the rest.

    Within the scripts.js file of the contact 7 form plugin I removed the .clearForm() method.

    if (1 == data.mailSent) {
    	$(data.into).find('form').resetForm().clearForm();
    	ro.addClass('wpcf7-mail-sent-ok');

    Changed to:

    if (1 == data.mailSent) {
    	$(data.into).find('form').resetForm();
    	ro.addClass('wpcf7-mail-sent-ok');

    Just remember that this is a “hack” and therefore any updates to CF7 will likely remove this alteration.

    Thanks Drunkard100 – you know, it feels odd referring to you as Drunkard100 Looks like we’d reached the same conclusion in relation to the clearForm() method. One question, are you defining a field as dynamic or how to you distinguish between fields you want reset and fields that aren’t?
    cheers
    Matt

    Thread Starter Drunkard100

    (@drunkard100)

    Hey Mamikel,

    I’m afraid I am a lil’ bit of a drunk :)…hehe. ??

    Anyway, I didn’t have to specify which fields I wanted to reset or not. Leaving the resetForm() method as it was kept it so that all the fields refreshed (reverting the dynamic fields back to the previous state, unaltered). This is the purpose of the resetForm() method.

    Removing the clearFrom() method made it so that the fields do not clear now. This was what I needed to fix. Now my users can enter project data into the form, and after submit (actually data.mailsent) the form refreshes to its previous state (with all non-dynamic fields empty, and the dynamic fields populated with the previous values). This way they can enter project data for one project and their identifying data (name, email, etc.) follows along to the next form, so that they only have to enter the new project specific data.

    One thing to note, one user has reported an issue with the form not wanting to validate (returning errors)on subsequent submits. However, no one else has been able to recreate this. I’m going to have them show me when I get the chance.

    Cheers back at ya!

    Thanks,
    I’ll enjoy a bourbon (Jim Beam of course) on your behalf then ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Keeping fields from refreshing on submit’ is closed to new replies.