F
Filamentβ€’9mo ago
Jon Mason

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>
<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');
}
}
class MonthSelector extends Field
{
protected string $view = 'forms.components.month-selector';

#[On('previousMonth')]
public function previousMonth()
{
dd('previous month');
}
}
3 Replies
Jon Mason
Jon Masonβ€’9mo ago
bump...if anyone has a moment to look at this i would appreciate it!
Jon Mason
Jon Masonβ€’9mo ago
ok, thanks for the link!