Calling method in custom field type
I'm trying to create a new custom form field and I'm wondering if there's a way to call a method from the component class.
For example, if I have the following form field
and the class
I get the following error
The method obviously exists, but I think it's because the dynamic component doesn't really know where to look. Ss there a way to call the custom
For example, if I have the following form field
and the class
I get the following error
Unable to call component method. Public method [doSomething] not found on componentThe method obviously exists, but I think it's because the dynamic component doesn't really know where to look. Ss there a way to call the custom
doSomething() function in a dynamic component?Solution
Form components aren't Livewire components, therefore your method cannot live in the custom field class.
You have two options:
You have two options:
- Add the method to the page (ListRecords, ViewRecord, CreateRecord, EditRecord)
- Use events instead of methods. See how its done in https://github.com/search?q=repo%3Asaade%2Ffilament-adjacency-list%20builder%3A%3Asort&type=code