# Id in repeater fields?

**URL:** <https://discourse.getcockpit.com/t/id-in-repeater-fields/1877>\
**Category:** Support\
**Created:** [March 16, 2021, 3:10pm UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877 "2021-03-16T15:10:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://discourse.getcockpit.com/u/buzz)\
**Post date:** [March 16, 2021, 3:10pm UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877/1 "2021-03-16T15:10:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 23, 2021, 10:21am UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877/2 "2021-03-23T10:21:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://discourse.getcockpit.com/u/buzz)\
**Post date:** [March 24, 2021, 12:13am UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877/3 "2021-03-24T00:13:08Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 24, 2021, 9:32am UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877/4 "2021-03-24T09:32:30Z")

</div>

> [@buzz](#):
>
> Unless there is a way to create a collection that dynamically adds other collections.

There are multiple options…

You could use the `collectionlink` field.

Or use the event system.

```php
$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.

---

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://discourse.getcockpit.com/u/buzz)\
**Post date:** [March 24, 2021, 5:01pm UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877/5 "2021-03-24T17:01:18Z")

</div>

@raffaelj Thanks!

> [@raffaelj](#):
>
> Or use the event system.

Where would I utilize these events ?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [March 25, 2021, 9:31am UTC](https://discourse.getcockpit.com/t/id-in-repeater-fields/1877/6 "2021-03-25T09:31:26Z")

</div>

> [@buzz](#):
>
> Where would I utilize these events ?

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