Repeater Index

How can I get the index of the repeater item? I want to add an index or id to each item when it saves to the database This is what I'm looking for, the index increments for each item in the repeater
[
{
"index": "1",
"toDate": "2014-02-16",
"fromDate": "2022-10-12",
}
{
"index": "2",
"toDate": "2014-02-16",
"fromDate": "2022-10-12",
}
]
[
{
"index": "1",
"toDate": "2014-02-16",
"fromDate": "2022-10-12",
}
{
"index": "2",
"toDate": "2014-02-16",
"fromDate": "2022-10-12",
}
]
6 Replies
Frank Wiebe
Frank WiebeOP13mo ago
Bumping this message
awcodes
awcodes13mo ago
In ->dehydrateStateUsing() loop through the array and set the index. Then return the array.
Frank Wiebe
Frank WiebeOP12mo ago
How do I loop through the array? or how do I access the array?
awcodes
awcodes12mo ago
dehydrateStateUsing(fn ($state) => loop state and return. It’s injected into the callback. Same as formatStateUsing or hydrateStateUsing.
Frank Wiebe
Frank WiebeOP12mo ago
That's what I needed. Thanks!
Want results from more Discord servers?
Add your server