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);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.