Id in repeater fields?

Is there anyway to get autogenerated IDs from the repeater fields ?

Please describe your actual goal a bit. Repeater fields produce arrays - without IDs. So waht do you want to get from the repeater field?

Hi @raffaelj - As an ecommerce solution; I want to verify the items on the backend by a unique identifier. Unless there is a way to create a collection that dynamically adds other collections. Or, if there is way to return all collections that belong to a group.

I’m currently using the repeater as so:

Main Category
– Sub Category (Sub Category Image)
— Sub Category Items (Items description, price etc)

There are multiple options…

You could use the collectionlink field.

Or use the event system.

$app->on('collections.save.before.collectionName1', function($name, $entry, $isUpdate) {
  // modify entry, e.g. add a unique id to sub items
  // or read/create an entry in a different collection
});

Or write a custom field, that creates unique ids and add that to a set field inside your repeater.

@raffaelj Thanks!

Where would I utilize these events ?

Inside /path/to/cockpit/config/bootstrap.php or in a custom addon.

1 Like