RepeaterEntry Action - How to get item data?

I hope someone can, help. In short I am displaying dropbox files on an infolist RepeaterEntry. I have added an Action button to download the file linked to it. I need to however get that specific row item data and im pulling my hair out on this one.
Action::make('dropbox')->button()->infolist(function (Infolist $infolist) {
$dropbox = new DropboxController();
$files = $dropbox->listFiles('Clients/XXXX');
return $infolist->state(['files'=>$files])->schema([
RepeatableEntry::make('files')->columns(2)->schema([
TextEntry::make('type'),
TextEntry::make('name'),
TextEntry::make('path')
->columnSpanFull()
->color('danger')
->suffixAction(
fn($state) =>
\Filament\Infolists\Components\Actions\Action::make('download')
->button()
->action(fn()=>DropboxController::downloadFolder($state))
),
\Filament\Infolists\Components\Actions::make([
\Filament\Infolists\Components\Actions\Action::make('download')
->button()
->action(fn(array $arguments, RepeatableEntry $component)=>dd($arguments))
])
])
]);
}),
Action::make('dropbox')->button()->infolist(function (Infolist $infolist) {
$dropbox = new DropboxController();
$files = $dropbox->listFiles('Clients/XXXX');
return $infolist->state(['files'=>$files])->schema([
RepeatableEntry::make('files')->columns(2)->schema([
TextEntry::make('type'),
TextEntry::make('name'),
TextEntry::make('path')
->columnSpanFull()
->color('danger')
->suffixAction(
fn($state) =>
\Filament\Infolists\Components\Actions\Action::make('download')
->button()
->action(fn()=>DropboxController::downloadFolder($state))
),
\Filament\Infolists\Components\Actions::make([
\Filament\Infolists\Components\Actions\Action::make('download')
->button()
->action(fn(array $arguments, RepeatableEntry $component)=>dd($arguments))
])
])
]);
}),
The suffix action is half way there but I actually also need to know the ''type'' so I know if I am downloading a file or folder. Does anyone know how to get the whole repeater item data?
Solution:
as always found the answer after posting. If anyone else needs it though here is answer: ``` ->action(function($arguments, $component){ if($component->getState()->type == 'folder') {...
Jump to solution
1 Reply
Solution
David | Fortune Validator
as always found the answer after posting. If anyone else needs it though here is answer:
->action(function($arguments, $component){
if($component->getState()->type == 'folder') {
return DropboxController::downloadFolder($component->getState()->path);
} else {
return DropboxController::downloadFile($component->getState()->path);
}
})
->action(function($arguments, $component){
if($component->getState()->type == 'folder') {
return DropboxController::downloadFolder($component->getState()->path);
} else {
return DropboxController::downloadFile($component->getState()->path);
}
})
Want results from more Discord servers?
Add your server