Home Forums Add-ons Repeater Field adding a row to a repeater Reply To: adding a row to a repeater

  • Hi @bosoxbill

    I’m afraid you have some syntax errors in your code. I believe you need to do it like this instead:

    // You need to set the variable instead of the value here
    function my_pre_save_post_x( $post_id ) {
    $row = array(
    	'game_date'	=> 'June 20, 1975',
    	'away_team'	=> 'Boston',
    	'away_score'	=> 0,
    	'home_team'	=> 'Cleveland',
    	'home_score'	=> 0,
    /* Please use the field key instead of the field name because you use it
     * before the saving process occured (pre_save_post). Also, you need to 
     * add the post ID to the add_row() function
    $i = add_row('field_1234567890abc', $row, $post_id);
    add_filter('acf/pre_save_post' , 'my_pre_save_post_x', 10, 1);

    To see the error message instead of the white screen, please take a look at this page:

    I hope this helps 🙂