© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
12 replies
Damien

Assigning actions to buttons correctly

I have created a custom view for my page and rather than using the default header actions, I want to use my own buttons and pass the correct method to each button.

Here is my widget class so far:

<?php

namespace App\Filament\Resources\ContactResource\Widgets;

use Filament\Actions;
use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class ContactOverview extends Widget
{
    protected static string $view = 'filament.resources.contact-resource.widgets.contact-overview';

    public ?Model $record = null;

    public function getIsSoftDeleted(): bool
    {
        return $this->record['deleted_at'] !== null;
    }

    public function edit(): void
    {
        Actions\EditAction::make();
    }

    public function delete(): void
    {
        Actions\DeleteAction::make();
    }

    public function forceDelete(): void
    {
        Actions\ForceDeleteAction::make();
    }

    public function restore(): void
    {
        Actions\RestoreAction::make();
    }
}
<?php

namespace App\Filament\Resources\ContactResource\Widgets;

use Filament\Actions;
use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class ContactOverview extends Widget
{
    protected static string $view = 'filament.resources.contact-resource.widgets.contact-overview';

    public ?Model $record = null;

    public function getIsSoftDeleted(): bool
    {
        return $this->record['deleted_at'] !== null;
    }

    public function edit(): void
    {
        Actions\EditAction::make();
    }

    public function delete(): void
    {
        Actions\DeleteAction::make();
    }

    public function forceDelete(): void
    {
        Actions\ForceDeleteAction::make();
    }

    public function restore(): void
    {
        Actions\RestoreAction::make();
    }
}


And here is the markup for my buttons:

<x-slot name="headerEnd">
    <div class="flex flex-col space-y-2 md:flex-row md:space-y-0 md:space-x-2">
        <x-filament::button wire:click="edit" class="w-28">
            Edit
        </x-filament::button>

        @if(!$this->getIsSoftDeleted())
            <x-filament::button wire:click="delete" color="danger" class="w-28">
                Delete
            </x-filament::button>
        @endif

        @if($this->getIsSoftDeleted())
            <x-filament::button wire:click="forceDelete" color="danger" class="w-28">
                Force Delete
            </x-filament::button>

            <x-filament::button wire:click="restore" color="gray" class="w-28">
                Restore
            </x-filament::button>
        @endif
    </div>
</x-slot>
<x-slot name="headerEnd">
    <div class="flex flex-col space-y-2 md:flex-row md:space-y-0 md:space-x-2">
        <x-filament::button wire:click="edit" class="w-28">
            Edit
        </x-filament::button>

        @if(!$this->getIsSoftDeleted())
            <x-filament::button wire:click="delete" color="danger" class="w-28">
                Delete
            </x-filament::button>
        @endif

        @if($this->getIsSoftDeleted())
            <x-filament::button wire:click="forceDelete" color="danger" class="w-28">
                Force Delete
            </x-filament::button>

            <x-filament::button wire:click="restore" color="gray" class="w-28">
                Restore
            </x-filament::button>
        @endif
    </div>
</x-slot>


When I click on one of the buttons, nothing happens but from what I've read online, this syntax should be correct?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Form Buttons and Page Actions Styles.
FilamentFFilament / ❓┊help
3y ago
Custom modal actions with multiple custom buttons
FilamentFFilament / ❓┊help
2y ago
extraAttributes on Bulk Actions not working correctly?
FilamentFFilament / ❓┊help
3y ago
How to translate buttons?
FilamentFFilament / ❓┊help
4mo ago