Support

Account

Home Forums ACF PRO ACF Form with Multiple Submit Buttons? Reply To: ACF Form with Multiple Submit Buttons?

  • This inserts a second button to an ACF form using jQuery.

    The form contains a hidden field ‘current_step’ which is set to a value of ‘1’ for normal submission.

    The second button includes onclick=”buttonA_clickHandler(event);” which overrides the saved hidden field ‘current_step’ value to 2.

    Its a quick (dirty) hack I have found useful.

    <?php
    acf_form(array(
    ‘post_id’ => $user_fact_find_id,
    ‘field_groups’ => array( 193 ),
    ‘id’ => ‘step1’,
    ‘html_after_fields’ => ‘<input type=”hidden” id=”hiddenId” name=”acf[current_step]” value=”1″/>’,
    ‘label_placement’ => ‘left’,
    ‘submit_value’ => __(‘Save Step 1’),
    ‘updated_message’ => __(“Post updated”, ‘acf’),
    ));
    ?>

    <input type=”submit” id=”myBtn” class=”acf-button2 button button-primary button-large” name=”4″ value=”Next” onclick=”buttonA_clickHandler(event);”>

    <script>

    jQuery(“#myBtn”).detach().appendTo(‘.acf-form-submit’);

    function buttonA_clickHandler(event) {
    document.getElementById(‘hiddenId’).value = 2;
    document.getElementById(‘step1’).submit();
    }

    </script>