Home › Forums › Add-ons › Repeater Field › Nested repeater and programmatically add values › Reply To: Nested repeater and programmatically add values
Please note the documentation that you must use field keys when adding values where they do not already exist. When using update_field() it is always safest to use field keys instead of field names.
Also note that the values you supply must be in the same format that ACF stores in the DB and NOT what you have set for the return format. I do not know what format this is for the time field. You should look in the database and make sure you are matching the value.
I would also suggest using a different sub field name for your repeater than then parent repeater name. Using the same name could potentially cause issues when using nested have_rows() loops.
To update a repeater field the value must be:
// you should replace all the field names with field keys
$value = array(
// nested array for each row of the repeater
array(
// field_key => value pairs for the row
'day' => 'DAY VALUE',
'working_hours' => array(
// this is a nested repeater, it follows the same pattern as the parent repeater
// nested array for each row
array(
// field_key => value pairs for the row
'from' => 'TIME',
'to' => 'TIME'
}
)
)
);
update_field('working_hours', $value, $post_id);
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.