Getting the current iteration for a repeatable entry in Infolist #9216
Replies: 4 comments 1 reply
-
Have you found a solution for this? |
Beta Was this translation helpful? Give feedback.
-
same here . Did you find a solution? @sherifiskander @cakanm |
Beta Was this translation helpful? Give feedback.
-
I ran into a need which I think is the same as this question. I was able to solve the problem (getting the data for the current iteration) like so: Components\RepeatableEntry::make('profiles')
->schema([
Components\ImageEntry::make('photo')
->label(function ($component) {
$index = explode('.', $component->getStatePath())[1];
$data = $component
->getContainer()
->getParentComponent()
->getState()[$index];
return $data['first'] . ' ' . $data['last'];
}),
// ...
]) Got the hints I needed to work this out from the following other discussions:
In my case I couldn't just inject the model for the repeated entry as it's not backed by any model at all (it's array data). |
Beta Was this translation helpful? Give feedback.
-
Is there a way to paginate a |
Beta Was this translation helpful? Give feedback.
-
I am trying to create a repeatable entry section that calls a function on the current array to generate the required text entries..
How can I find the current index of the repeater in infolist.
I am able to get the record using
$inforecord = $infolist->getRecord();
but the in the repeater I need to know which iteration is the repeater on so I can call a function using $inforecord[INDEX]
Beta Was this translation helpful? Give feedback.
All reactions