I’m new in Cockpit, I’d like to create a simple shopping cart, I can save simple field but having trouble to save Repeater-Set field type.
This field is simply a repeater with fields Quantity (number) and Product ( collectionlink )
Repeaters are complicated… They store all field definitions for each entry, so you have to send them with your api requests, too. They are more for the ui usage.
If you want to keep the structure, create an entry with your admin ui, get the data via api and have a look at the structure. Then build a request with the same structure.
The problem is, that repeaters can have all types of fields in different orders and they need a mechanism to know the field definitions for each value.
This worked for me, but it’s ugly: /api/collections/save/reptest?token=xxtokenxx
json:
I would lean back and think about a structure without repeaters, e. g. with multiple collections and collectionlinks.
Or I would built a custom field for my needs. Have a look at the simple-repeater field, that I built a while ago for inspiration: .tag file, usage
If you can’t find a smaller structure, you can build your own api endpoint in /config/bootstrap.php, that adds the field definitions automatically. If you need help with this approach, feel free to ask again.
But you have a collection link field and your products title is stored in the nested key product.display. I don’t see a way to display that with the current setup, sorry.
But as always - there are multiple ways to achieve the goal.
Use a third field inside set for displaying in the admin ui and send/change the product title manually.