marcosmarcolin
marcosmarcolin
FFilament
Created by marcosmarcolin on 2/20/2024 in #❓┊help
Redirect with ->url() with bulk action?
I have a table and I would like to redirect to a route after selecting some records from the table. I tried using ->url(), but it doesn't work, is it possible? My code is this:
BulkAction::make('pdf')->label('Generate PDF')->icon('heroicon-o-document')
->color('info')
->url(fn ($records): string => route('step.pdf', ['steps' => $records]))
->openUrlInNewTab()
BulkAction::make('pdf')->label('Generate PDF')->icon('heroicon-o-document')
->color('info')
->url(fn ($records): string => route('step.pdf', ['steps' => $records]))
->openUrlInNewTab()
Any ideas on how to resolve it? I tried with Action also returning route, but it was not possible. Thanks.
2 replies
FFilament
Created by marcosmarcolin on 11/16/2023 in #❓┊help
Retrieve ID of selected child from related table
Hello everyone, I can't retrieve the id of the table related to the Resource, is there any way? Ex: I have a Questions Resource and it has a Relationship with Options. When I edit a Question it lists all the Options, so far ok. I'm doing a custom action on the relationship, and I would like to retrieve the id of the record I'm clicking on. When I use $this->getOwnerRecord() I am retrieving the id of the Father, is there a way to retrieve the id of the selected child?
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('questions')->label('')->icon('heroicon-o-question-mark-circle')
->action(
fn () => redirect()->route('filament.admin.resources.onboarding.show-questions', [$this->getOwnerRecord(), ?])
),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('questions')->label('')->icon('heroicon-o-question-mark-circle')
->action(
fn () => redirect()->route('filament.admin.resources.onboarding.show-questions', [$this->getOwnerRecord(), ?])
),
])
My route/page expects two parameters, I send the first with $this->getOwnerRecord(), but the second, which would be the id of the selected line, I cannot retrieve. Thanks.
2 replies