F
Filament13mo ago
Hugo

Collapse all previous repeater items on addAction

Hi, On my repeater, what can I do so that when I click on the button to add an item, all previous items become collapsed? I can't find a solution in the documentation
Forms\Components\Repeater::make('services')
->label('Services')
->hintIcon('heroicon-o-information-circle', 'Ignorez cette étape si vous ne souhaitez pas associer de service au bénévole.')
->hintColor('primary')
->addActionLabel('Ajouter un service au bénévole')
->reorderableWithDragAndDrop(false)
->collapsible()
->defaultItems(0)
->itemLabel(fn(array $state): ?string => Service::find($state['service_id'])->serviceType->name ?? null)
->deleteAction(fn(Action $action) => $action->requiresConfirmation())
->schema([...]),
Forms\Components\Repeater::make('services')
->label('Services')
->hintIcon('heroicon-o-information-circle', 'Ignorez cette étape si vous ne souhaitez pas associer de service au bénévole.')
->hintColor('primary')
->addActionLabel('Ajouter un service au bénévole')
->reorderableWithDragAndDrop(false)
->collapsible()
->defaultItems(0)
->itemLabel(fn(array $state): ?string => Service::find($state['service_id'])->serviceType->name ?? null)
->deleteAction(fn(Action $action) => $action->requiresConfirmation())
->schema([...]),
Thanks for your help.
3 Replies
LeandroFerreira
LeandroFerreira13mo ago
->addAction(
fn (Action $action) => $action->extraAttributes(fn($component) => [
'x-on:click' => new HtmlString('$dispatch(\'repeater-collapse\', \''.$component->getStatePath().'\')')
])
)
->addAction(
fn (Action $action) => $action->extraAttributes(fn($component) => [
'x-on:click' => new HtmlString('$dispatch(\'repeater-collapse\', \''.$component->getStatePath().'\')')
])
)
Hugo
HugoOP13mo ago
It works! Thanks a lot ! 😄
LeandroFerreira
LeandroFerreira13mo ago
it could be better, but it works
Want results from more Discord servers?
Add your server