• Resolved yepecece

    (@yepecece)


    Hi,

    I am using the Front-end form which is great.

    I need to play a Bodymovin animation on form success.

    What would be the correct way to disable redirection/reload of the page as well as to fire a function on form submission success?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback. You can disable the form redirection by simply leaving the “Redirection” setting empty in the ACF Extended Form UI. This will reload the page, without any redirection. The page reload on submission is a core logic of ACF Form, and cannot be disabled.

    Concerning the JS function on form submission success, you can use specific JS hooks:

    
    // All forms
    acf.doAction('acfe/form/submit/success');
    
    // Form ID: 123
    acf.doAction('acfe/form/submit/success/id=123');
    
    // Form Name: my-form
    acf.doAction('acfe/form/submit/success/name=my-form');
    

    Usage example:

    
    (function($){
    
        if(typeof acf === 'undefined')
            return;
    
        acf.addAction('acfe/form/submit/success/name=my-form', function(){
    
            alert('success');
    
        });
    
    })(jQuery);
    

    Remember to enqueue the JS file using acf/input/admin_enqueue_scripts just like in the documentation: https://www.advancedcustomfields.com/resources/acf-input-admin_enqueue_scripts/

    
    add_action('acf/input/admin_enqueue_scripts', 'my_acf_admin_enqueue_scripts');
    function my_acf_admin_enqueue_scripts(){
    	wp_enqueue_script('acf-js', get_stylesheet_directory_uri() . '/acf.js', false);
    }
    

    Hope it helps!

    Regards.

    Thread Starter yepecece

    (@yepecece)

    Thanks for all these clarifications.

    Since I really need to avoid the page reload I will need to use some other plugin for my forms right now.

    Let me know if you plan to add the possibility to avoid the page reload and rely only on Ajax for the submission as an option.

    Thank you

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I already found a “hacky” way to use Ajax for form submission, but an ACF update could break it which made it not reliable enough for production websites (as it possibly needs maintenance & upgrades). Unless ACF provide a native way to submit ACF Forms using Ajax, I would stay away from it.

    Regards.

    Thread Starter yepecece

    (@yepecece)

    Thanks for the info.

    I saw your post on the ACF support forum as well as your exemples.

    In the mean time I have already setup my form with ninja form which works fine.
    I really want to avoid using it in the future and might try this on my next project.

    Thanks and I hope acf implements this so that we can use it in a less hacky way.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Well, that post on the forum is already deprecated and isn’t working anymore. I don’t know if that’s on the todo list of ACF tho. I’ll try to submit the feature request on Github.

    Regarding ACF Extended: Forms, I would suggest you to test it, because it is a very very powerful feature, I think you gonna like it 🙂

    Regards.

    Thread Starter yepecece

    (@yepecece)

    Hi,

    In fact i tried it and was really happy with it.

    The only problem is that for this specific project I needed Ajax submission.

    For any other project I will definitely be using ACF extended: Forms.

    Thanks again and keep me posted if you have news regarding Ajax submissions.

    Best.

    • This reply was modified 5 years, 11 months ago by yepecece.
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Disable redirection and launch js function on success’ is closed to new replies.