Support

Account

Home Forums ACF PRO Use acf_form within a Loop

Solving

Use acf_form within a Loop

  • Hi there,

    I have a foreach loop that contains various acf_form like:

    
    if( have_rows('my_repeater',$my_id) ):
    	$i = 0;
    	while ( have_rows('my_repeater',$my_id) ) : the_row();
    	$i++
    	// Doing other stuff non acf-related
    	$form_options = array(
    		'post_id'          => $my_id,
    		'new_post'         => false,
    		'post_title'       => false,
    		'field_groups'     => array(
    			1234
    		),
    		'fields'           => array(
    			'field_12345', // Can I do the equivalent of [field_12345][$i]..i.e. get a specific repeater sub-field in an acf_form?
    			// "field_12345[$i]", // Does nothing
    			// "[$i]field_12345", // Does nothing
    			// "ffield_12345_[$i]", // Does nothing
    		),
    		'submit_value'     => 'Reply',
    		'updated_message'  => __('Thanks', 'acf'),
    		'return'           => '?updated="true'
    	);
    	acf_form($form_options);
    	
    	endwhile;
    endif;
    

    What I would like to know is if I can target a specific repeater subfield in an acf_form. Or is there a filter that I can run to add the correct row to each field?

    Essentially, I want to have a submit button/form for each repeater row independently as opposed to one submit button for all repeater rows

    Thanks in advance!

  • Sorry to say this, but no, there isn’t any way to do this, not without building your own form(s) and your own php to process the submitted values.

  • Thanks for letting me know John. I was able to find a workaround using a custom post_meta array field and acf/save_post but had to do away with the repeater.

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

The topic ‘Use acf_form within a Loop’ is closed to new replies.