wire:click not working inside of custom field, method not found.

Maybe I'm doing this wrong, but I want to call a method on my custom field component when a user clicks a button in the same component.

<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
    <div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
        <div class="max-w-lg p-36 container flex justify-end mx-auto self-center">
            <div class="flex flex-row h-10 w-15">
                <x-filament::icon-button icon="heroicon-m-chevron-left" class="self-center" size="xl" wire:click="previousMonth" />
                <span class="self-center py-6 px-4">{{ $getState() }}</span>
                <x-filament::icon-button icon="heroicon-m-chevron-right" class="self-center" size="xl" wire:click="nextMonth" />
            </div>
        </div>
    </div>
</x-dynamic-component>


wire:click results in a method not found on component error. I'm doing this on the backend:

class MonthSelector extends Field
{
    protected string $view = 'forms.components.month-selector';

    #[On('previousMonth')]
    public function previousMonth()
    {
        dd('previous month');
    }
}
Was this page helpful?