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>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.