Home Forums Add-ons Repeater Field Add Repeater Row From Another Field Reply To: Add Repeater Row From Another Field

  • Sigh, sometimes I feel like when I post here, the solution is about 5 minutes away. Turns out that I was missing the $post_id in the add_row() function.

    So, the code that I have and is now working is:

    function add_repeater_row_on_save($post_id) {	
    	$my_textarea = get_field('my_textarea'); // My textarea field
    	$row = array(  // my repeater sub-field
    		'field_1s'	=> 'Repeater sub-field 1 text',
    		'field_2S'	=> 'Repeater sub-field 2 text',
    		'field_3s'	=> 'Repeater sub-field 3 text',
    	$i = add_row('field_repeater', $row,$post_id); // The $post_id here was missing
    	// Reset Textarea
    	update_field('my_textarea', '', $post_id);
    add_action('acf/save_post', 'add_repeater_row_on_save', 20);