Hi there,
Thank you for contacting us.
Nigel will be away on vacations until next week and I'll be helping you with this ticket.
The process to update the custom field value will be different if the field is a "repeating field" ( ref: https://toolset.com/documentation/user-guides/repeating-fields/ ) or is a part of a "repeating field group" ( ref: https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/ ).
A. Case - Repeating field:
As explained in the documentation ( ref: https://toolset.com/documentation/user-guides/repeating-fields/#How%20Types%20Stores%20Repeater%20Fields ), Types stores repeating fields as individual post-meta in the database. This means that when you add another field, a new post-meta is created with the same key, but a different value.
If you need to add multiple values/entries for a repeating field, you can use "add_post_meta" function, instead of "update_post_meta"
( ref: https://codex.wordpress.org/Function_Reference/add_post_meta )
The "update_post_meta" function updates the value of the existing custom field entry and only adds a new one if it doesn't already exist.
B. Case - Field in Repeating Field Group:
When a repeating field group is created, a new hidden post type is also created in the backend, with the same slug as that repeating field group.
( example screenshot: hidden link )
Also, a hidden relationship with the same slug is also created between this new post type (child) and the parent post type, for which this repeating field group was added.
Any fields which are added as part of that repeating field group, are saved as custom meta field entries against this new custom post type (child) and not the parent one.
For example, suppose you have a "Product" post type, for which you have a repeating field group called 'Product Features' (slug: product-features).
When you'll insert a new post in "Product" post type using the code, you'll also need to insert a new post in the hidden post type "product-features".
After that, you can connect the IDs of the newly added "Product" (parent) and "Product Features" (child) into a relationship, using the "toolset_connect_posts" function.
( ref: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts )
As for the custom fields, you can add or update them using the ID of that new "Product Feature" post and not the "Product" post.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar