F
Filament10mo ago
cakan

DeleteAction throws error on custom header

I have created a custom header for my page and added this code to the header:
@if ($this->getHeaderActions())
<x-filament-tables::actions
:actions="$this->getHeaderActions()"
@class([
'shrink-0',
'sm:mt-7' => $this->getBreadcrumbs(),
])
/>
@endif
@if ($this->getHeaderActions())
<x-filament-tables::actions
:actions="$this->getHeaderActions()"
@class([
'shrink-0',
'sm:mt-7' => $this->getBreadcrumbs(),
])
/>
@endif
Code for my page looks like this:
class ViewCompany extends ViewRecord
{
protected static string $resource = CompanyResource::class;

public function getHeader(): ?View
{
return view('filament.custom.header');
}

protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
class ViewCompany extends ViewRecord
{
protected static string $resource = CompanyResource::class;

public function getHeader(): ?View
{
return view('filament.custom.header');
}

protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
What I want to achieve is to have Delete button on viewPage header. But I keep getting error saying "Filament\Actions\DeleteAction::Filament\Actions{closure}(): Argument #1 ($record) must be of type Illuminate\Database\Eloquent\Model, null given, called in \vendor\filament\support\src\Concerns\EvaluatesClosures.php on line 35" If I put regular Action or EditAction instead of DeleteAction, it works as expected, What am I missing?
Solution:
Just create your own delete action? The DeleteAction is designed for a form page not view pages
Jump to solution
1 Reply
Solution
toeknee
toeknee10mo ago
Just create your own delete action? The DeleteAction is designed for a form page not view pages
Want results from more Discord servers?
Add your server