Support

Account

Home Forums Front-end Issues Multiple acf_form one submit

Solved

Multiple acf_form one submit

  • Hi there!

    I have a pretty advanced <table> with cells that I need to be able to edit and save/update frontend. Therefor I thought that acf_form would be the way to go here after creating all <td> as custom fields.

    My problem is that it’s not so easy to setup the html for acf_form.

    So either I want to output all <input id=”field…>” (like attached image) and the do alot of appendto for each <td>.

    Or instead create one acf_form for each <td> and at the bottom of the table add a button to submit all my acf_forms. I guess this the best way. But how do i output multiple forms (one for each custom field) on a single post and only one button to submit them all?

    output

    code

  • Hi @dilladakilla

    In this case, you need to set the form option to false and add the form and submit button tag manually. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acf_form/. It should be something like this:

    <form id="post" class="acf-form" action="" method="post">
    
        <?php acf_form(array(
            'field_groups' => array(7),
            'form' => false,
        )); ?>
    
        <?php acf_form(array(
            'field_groups' => array(9),
            'form' => false,
        )); ?>
    
        <div class="acf-form-submit">
            <input type="submit" class="acf-button button button-primary button-large" value="Update">
            <span class="acf-spinner"></span>
        </div>
    
    </form>

    I hope this helps 🙂

  • Works perfect, thanks a lot!

    Now I just need to implement an ajax submit so the page doesnt reload when I updated all my fields 🙂

  • Hi @james.

    Its been a few years but i’m just picking up on this example. I have it working but it’s saving to the page postID and not the ID of the CPT that i want to save too. Is there a way to do it this way. Normally i can just put the postID in the the acf_form and it works but that won’t work for the page i’m building.

  • Hi @james

    Could you please tell me how, in your previous example, I can add the following code, in order for me to create a new post ?

    'new_post' => array(
           'post_type' => 'questionnaire_ws',
           'post_status' => 'publish',
           'post_title' => 'lorem test',
    ),

    My goal is to create a post type “questionnaire_ws” with multiple acf groups 🙂

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.