Support

Account

Home Forums Add-ons Repeater Field Front-end forms and repeater fields – only show new entry row Reply To: Front-end forms and repeater fields – only show new entry row

  • Hi @speccydan

    The only way I can think to do this would be to add a new text field (similar name to the repeater

    Then add the form to your template but use:
    'fields' => array(), #this is a comma separated list of field keys for each field you need in your form

    Ensure you don’t include the repeater field but instead the new text field!

    When the form is triggered, use the acf/save_post function.

    Within the function, you can then grab the text field and pass the data into the repeater using the add_row function, for example:

    function my_acf_save_post( $post_id ) {
    
        // Get newly saved values.
        $values = get_fields( $post_id );
    
        // Check the new value of a specific field.
        $new_text_field = get_field('new_text_field', $post_id);
        if( $new_text_field ) {
    
    		$row = array(
    			'field_5947dbd28c36e' => $new_text_field,
    		);
    
    		add_row('field_5947dbbd8c36d', $row, $post_id);	#change this to your main repeater key ID	
    		
        }
    }
    #acf/save_post action after ACF has saved the $_POST data. This is possible by using a priority greater  than 1.
    add_action('acf/save_post', 'my_acf_save_post', 20);

    It’s a little long winded but not sure how else to do it! Code is purely as a guide, not tested and may need refining!