Incremental itemLabel for repeater
Hello everyone. 👋
I know this question has already been asked several times, but I haven't found any answers...
Basically my question is simple: I'm creating a form with a repeater (questions). In this repeater, I've a second one (answers).
And I want to put an itemLabel in this second repeater with an incremental number (Answer 1, Answer 2, Answer 3, etc.).
Thanks for you help 😅
Solution:Jump to solution
I found a solution on Github for those who are looking too :
```php
->itemLabel(function ($state, $component) {
$key = array_search($state, $component->getState());...
GitHub
How to add index on Repeater itemLabel ? · filamentphp filament · D...
https://filamentphp.com/docs/3.x/forms/fields/repeater#adding-a-label-to-repeater-items-based-on-their-content ->itemLabel(fn (array $state): ?string => $state['name'] ?? null)
2 Replies
Solution
I found a solution on Github for those who are looking too :
And that work like expected 🥳
Source : https://github.com/filamentphp/filament/discussions/8565#discussioncomment-7031649
GitHub
How to add index on Repeater itemLabel ? · filamentphp filament · D...
https://filamentphp.com/docs/3.x/forms/fields/repeater#adding-a-label-to-repeater-items-based-on-their-content ->itemLabel(fn (array $state): ?string => $state['name'] ?? null)
hi
@Alexandre hi sorry for mentioned you here. may i know that this code still function ? because i try implement to my project but seems not working