F
Filamentβ€’11mo ago
Abi

`EditAction` and `DeleteAction` on a ViewRecord's `getHeaderActions` method throws an error

I have the following ViewRecord page for a resource and adding HeaderActions EditAction and DeleteAction throws an error.
use App\Filament\Resources\Store\StoreResource;
use Filament\Resources\Pages\ViewRecord;
use Filament\Actions;

class ViewStore extends ViewRecord
{
protected static string $resource = StoreResource::class;

protected function getHeaderActions(): array
{
return [
Actions\EditAction::class,
Actions\DeleteAction::class,
];
}
use App\Filament\Resources\Store\StoreResource;
use Filament\Resources\Pages\ViewRecord;
use Filament\Actions;

class ViewStore extends ViewRecord
{
protected static string $resource = StoreResource::class;

protected function getHeaderActions(): array
{
return [
Actions\EditAction::class,
Actions\DeleteAction::class,
];
}
Error
Header actions must be an instance of Filament\Actions\Action, or Filament\Actions\ActionGroup.
Header actions must be an instance of Filament\Actions\Action, or Filament\Actions\ActionGroup.
Any advice.
Solution:
actually figured it out just now after looking at the docs. need to call the make() method for the class replaced my code with and it worked ```php...
Jump to solution
4 Replies
Weccop
Weccopβ€’11mo ago
Action\EditAction::class, Action\DeleteAction::class, I thinks this will solve it. Or Change it to this: EditAction::class, DeleteAction::class, And change the use from: use Filament\Actions; to use Filament\Actions\Action; https://filamentphp.com/docs/3.x/panels/pages#header-actions
Abi
AbiOPβ€’11mo ago
@Weccop , that same code I posted works for the EditRecord page for the resource, not the ViewRecord and the is no namespace Filament\Actions\Action
Solution
Abi
Abiβ€’11mo ago
actually figured it out just now after looking at the docs. need to call the make() method for the class replaced my code with and it worked
Actions\EditAction::make(),
Actions\DeleteAction::make(),
Actions\EditAction::make(),
Actions\DeleteAction::make(),
Weccop
Weccopβ€’11mo ago
Ah nice. Didnt see that one πŸ™‚
Want results from more Discord servers?
Add your server