Home › Forums › ACF PRO › Updating Repeater Fields: update_field() vs. add_row() › Reply To: Updating Repeater Fields: update_field() vs. add_row()
When you use update_field() you would need to include all of the existing values along with the new values. This means that you need to first get all the existing values and then add a new row to it and then use update_field().
When using add_row(), the value you’re using is incorrect. For update_field() it should be the nested array that you have, each row being nested in the repeater. However, when updating a single row this array should not be nested.
$value =
array(
'field_5c4b34917ab9b' => implode(', ', $regions), // text area (sub field)
'field_5c4b34c87ab9c' => implode(', ', $sectors), // text area (sub field)
'field_5c4b34d17ab9d' => date('Y-m-d H:i:s', time()) // text (sub field)
);
add_row($field_key, $value, $pressReleaseID);
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.