F
Filament14mo ago
cakan

Action not working in custom view

I have a custom page with action defined like this:
public function downloadBookAction(): Action
{
return Action::make('downloadBook')
->action(function (array $arguments) {
$this->book = Book::findOrFail($arguments['id']);
return Storage::disk('public')->download($this->book['file']);
});
}
public function downloadBookAction(): Action
{
return Action::make('downloadBook')
->action(function (array $arguments) {
$this->book = Book::findOrFail($arguments['id']);
return Storage::disk('public')->download($this->book['file']);
});
}
In blade for my custom view I have this line
{{ ($this->downloadBookAction)(['id'=>$book->id]) }}
{{ ($this->downloadBookAction)(['id'=>$book->id]) }}
This works as expected and clicking on a button starts file download. Later, on same custom page I have a modal dialog with Book details this modal uses another custom view:
View::make('bookDetails')->model(fn () => $this->book)->view('filament.resources.book-resource.pages.actions.book-details')
View::make('bookDetails')->model(fn () => $this->book)->view('filament.resources.book-resource.pages.actions.book-details')
But here the action defined in my custom page doesn't work. Code recognizes the downloadBookAction and the button is displayed with all formatting, icon, etc. but when I click on the button, nothing happens - it never gets into the ->action() method. What am I doing wrong?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?