Support

Account

Home Forums Add-ons Repeater Field Save sum of repeater filed into another filed Reply To: Save sum of repeater filed into another filed

  • I tried this with no difference

    function my_acf_update_totalexpenses($post_id)
    {
    
       $total = get_sub_field('list'); $totaltasks = count($tasks);
    	$totaltaskpercentage = 0;
    		while ( have_rows('list') ) : the_row(); 
    			$totaltaskpercentage += intval( get_sub_field('expense_'));
    		endwhile; 
    	$grouptaskpercentage = $totaltaskpercentage / $totaltasks;
    	echo round($grouptaskpercentage);
    	$value = $total;
        $field_name = "_totalexpenses";
        update_field($field_name, $value, $post_id);
    }
    add_action('acf/save_post', 'my_acf_update_totalexpenses', 20);