Home Forums ACF PRO acf_form submitting via ajax currently broken


acf_form submitting via ajax currently broken

  • I have an acf_form submitting via AJAX. I understand that acf.validation.toggle has been removed as of 5.7 (why??). I attempted to replace it with acf.unlockForm, and the submission will go through, all the JS code runs and works, except the call to acf.unlockForm.

    Why does the form lock itself without any of my code getting thrown in, but requires me to call an unlock on it? I’m guessing because I’m actually handling the AJAX?

    What is the best way to have an acf_form printout, with display and validation handled by acf, but I get to hook onto the form to clear only specific fields and things?

    This is the slightly anonymized version of what I’m currently doing (in 5.6.10):

    		'id'			=> 'FORMNAME_HERE',
    		'post_id'		=> 'new_post',
    		'post_title'	=> false,
    		'post_content'	=> false,
    		'fields' => array(
    		'new_post'		=> array(
    			'post_type'	=> 'CPT_HERE',
    			'post_status'	=> 'publish'
    		'submit_value'	=> 'Submit',
    		'return' => '',
    		'updated_message' => 'Updated.',
    		'honeypot' => false
    	// ready ACF
    	acf.do_action('ready', $('body'));
    	// disable the ACF js navigate away pop up = false;
    	// prevent page reload on submit
    	$('.acf-form').on('submit', function(e){
    	// hook onto the acf submit action, ajaxify
    	acf.add_action('submit', function($form){
    			url: window.location.href,
    			method: 'post',
    			data: $form.serialize(),
    			success: function(data) {
    				// unlock the form
    				acf.validation.toggle($form, 'unlock');
    				// show data
    				$('.timelog-table tbody').prepend(data);
    				// remove errors
    				// remove some selected values, keeping others for fast entry
  • The JD API for ACF was completely rebuilt for ACF 5.7. Form the most part a lot of custom JS built for ACF prior to 5.7 will no longer work. This is the new documentation

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘acf_form submitting via ajax currently broken’ is closed to new replies.