F
Filament7mo ago
Jordy

getTableRecordUrlUsing a new tab

https://filamentphp.com/docs/2.x/tables/getting-started#record-urls I have this but want to open the url in a new tab (links to an external site).. can I do so or do I have to define ->url() and ->openUrlInNewTab() on every column?
5 Replies
jaocero
jaocero7mo ago
maybe you can use redirect(route('your_route)) ?
Dennis Koch
Dennis Koch7mo ago
This is View and EditAction, right? Can't you set ->openUrlInNewTab() on those?
links to an external site
What's the code for this?
Jordy
Jordy7mo ago
its a clickable row, I am not linking to an action but an external url thats why I want it in another tab
protected function getTableRecordUrlUsing(): Closure
{
return fn(OrderItem $record): string => 'xxx' . $record->article_number;
}
protected function getTableRecordUrlUsing(): Closure
{
return fn(OrderItem $record): string => 'xxx' . $record->article_number;
}
Dennis Koch
Dennis Koch7mo ago
Use getTableRecordActionUsing() and use an action with url() and openUrlInNewTab()
Jordy
Jordy7mo ago
do you have an example on how you would do this? I cant figure out how to do it using an Action it works as a table action now but not using the clickable row
protected function getTableRecordActionUsing(): ?Closure
{
return fn(): string => 'check';
}
protected function getTableRecordActionUsing(): ?Closure
{
return fn(): string => 'check';
}
and the check is as you said, which works when pressed directly as a normal action.. but not when clicking on the row/record
Action::make('check')
// ->action(fn(ChecklistItem $record) => dd($record))
->url('/test', true)
Action::make('check')
// ->action(fn(ChecklistItem $record) => dd($record))
->url('/test', true)
the action it does work when I am using the commented action (dd's on click) but when commented out it doesnt do anything except when just pressing the action normally, then it works as expected php/laravel cant open a new tab might just keep the current url and add an action to open in new tab..