Support

Account

Home Forums ACF PRO Edit multiple post at once using acf_form

Solved

Edit multiple post at once using acf_form

  • Hi,
    I’m looking for a way to edit multiple posts fields in front end using acf_form.
    For now I’ve created a front end form and set the form parameters to false as mentioned in this thread : https://support.advancedcustomfields.com/forums/topic/split-up-an-acf_form-into-a/

    But only my last post is saving.

    Here is my code :

    <form id="acf-form" class="acf-form" action="" method="post">
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>Nom</th>
                        <th class="accreditation">Accréditation</th>
                    </tr>
                </thead>
                <tbody>
                <?php $args = array(
                    'post_type' => array( 'evenement' ),
                );
                $evenements = new WP_Query( $args );
                if ( $evenements->have_posts() ) {
                    while ( $evenements->have_posts() ) {
                        $evenements->the_post(); ?>
                <tr>
                    <td><?php the_title(); ?></td>
                    <td>
                    <?php $options = array(
                        'field_groups'	=> array('group_5aafe1f54cc6c'),
                        'updated_message' => false,
                        'post_id' => $post->ID,
                        'form' => false,
                    );
                    acf_form( $options ); ?>
                    </td>
                </tr>
                <?php }
                }
                wp_reset_postdata(); ?>
                </tbody>
            </table>
        </div>
        <div class="acf-form-submit">
            <input type="submit" class="acf-button button button-primary button-large" value="Mettre à jour">
            <span class="acf-spinner"></span>
        </div>
    </form>
  • The problem is that all the fields have the same names/keys, so you have multiple input fields with the same name. The later fields of a name overwrite the earlier fields with the same name. For this reason, editing multiple posts with the same fields will not be possible using acf_form().

  • Ok thanks for the explanation, is there a way to save fields without reloading page ?

  • Thanks @hube2 !
    That topic helped me.

    I was wondering if I could automatically update field without clicking on the update button. This way, each time a field is edited, it’s updated by ajax automatically.

    This would solve my problem and avoid client to forget pressing button when editing multiple post.

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

The topic ‘Edit multiple post at once using acf_form’ is closed to new replies.