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 ?
follow this topic, it looks to have several answers. https://support.advancedcustomfields.com/forums/topic/frontend-form-post-via-ajax/
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.
The topic ‘Edit multiple post at once using acf_form’ is closed to new replies.
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.