How to add a method to a custom component?
Currently I am getting this error:
when I try to run a custom method called
I have followed this:
https://filamentphp.com/docs/3.x/forms/fields/custom
and created the custom component files (component class file and blade view class) via this command:
I can do the blade view and create bells and whistles.
But, in this custom component, I would like to bypass the form actions Save, Cancel, etc. and trigger my own Livewire functions.
So, I added `wire:click="saveCarState" on one of my buttons.
And I expect that when the user clicks on this button the function saveCarState in the file (that was created by the artisan command):
will be triggered.
So, I added it there like:
But I am getting the error message as I said in the beginning.
How can I use Livewire method in my custom component?
Clearly I am doing something wrong here
when I try to run a custom method called
saveCarState when clicking on a button like:I have followed this:
https://filamentphp.com/docs/3.x/forms/fields/custom
and created the custom component files (component class file and blade view class) via this command:
I can do the blade view and create bells and whistles.
But, in this custom component, I would like to bypass the form actions Save, Cancel, etc. and trigger my own Livewire functions.
So, I added `wire:click="saveCarState" on one of my buttons.
And I expect that when the user clicks on this button the function saveCarState in the file (that was created by the artisan command):
will be triggered.
So, I added it there like:
But I am getting the error message as I said in the beginning.
How can I use Livewire method in my custom component?
Clearly I am doing something wrong here
Solution
saveCarState method should exist in the CreatePage, EditPage, if you are using the panel builder, or in the LW component if you are using a custom LW component.