Go to other page with params in the url when click an action.

Hi, I make a custom page with a livewire component with a filament table to list projects. Now I've create a new custom page like a produc view and i want to have the name of the project in the url. the url of the page that i need is this -> 'tests/{nameOfTheProject}' How can I do this redirection when the action of the line in the table is clicked or when the name of the project in the table is clicked? PD: the resource is not a Project Resource, so I can't use default pages of filament, i need to do custom pages because in this resource i'm matching a lot of info of diferent models.
2 Replies
Patrick Boivin
I think this should work:
Action::make('my_action')
->url(fn ($record) => CustomPage::getUrl(['my_param' => $record->some_property]))
Action::make('my_action')
->url(fn ($record) => CustomPage::getUrl(['my_param' => $record->some_property]))
jals65
jals65OP2y ago
I do that buit when it calls, I get this error: Route [filament.pages.project-visual-tests] not defined.
protected function getTableActions(): array
{
return [
\Filament\Tables\Actions\Action::make('view')->url(function ($record) {
return ProjectVisualTests::getUrl(['project' => $record->project]);
})
];
}
protected function getTableActions(): array
{
return [
\Filament\Tables\Actions\Action::make('view')->url(function ($record) {
return ProjectVisualTests::getUrl(['project' => $record->project]);
})
];
}
<?php

namespace App\Filament\Resources\VisualTestingResource\Pages;

use App\Filament\Resources\VisualTestingResource;
use Filament\Resources\Pages\Page;

class ProjectVisualTests extends Page
{
protected static string $resource = VisualTestingResource::class;

protected static string $view = 'filament.resources.visual-testing-resource.pages.project-visual-tests';
}
<?php

namespace App\Filament\Resources\VisualTestingResource\Pages;

use App\Filament\Resources\VisualTestingResource;
use Filament\Resources\Pages\Page;

class ProjectVisualTests extends Page
{
protected static string $resource = VisualTestingResource::class;

protected static string $view = 'filament.resources.visual-testing-resource.pages.project-visual-tests';
}
I get it using the resource.
protected function getTableActions(): array
{
return [
Action::make('view')->url(fn ($record) => VisualTestingResource::getUrl('project-visual-tests', ['project' => $record->project]))
];
}
protected function getTableActions(): array
{
return [
Action::make('view')->url(fn ($record) => VisualTestingResource::getUrl('project-visual-tests', ['project' => $record->project]))
];
}
Want results from more Discord servers?
Add your server