Trying to modify filament form fields from custom Livewire Field component.
I want to be able to update a couple of fields in a filament 'step' based form by using a google-maps-api clickable map. I'm trying to learn livewire a bit more while doing it and am loading the map code into a livewire component, but I can't seem to figure out how you are supposed to take data coming back from the map 'click' listener event and then have filament update the lat and lng fields in the form.
Since I strongly suspect all my attempts have been blind shots in the dark or are offtrack. So does anyone have any suggestions on how to do this?
3 Replies
First I create a rather bare-bones extension of 'Field' that points to a blade template:
fetchGoogle is just a promise based series of steps that first gets my API key, then downloads the google.maps api code using the key, then launches my initializeMap function.
The map code works fine, but I don't know how to handle the 'click' listener or how to grab any of the resulting details back in filament to update the form:
The Filament Step form schema is rather basic:
the 'afterStateUpdated code never seems to run, so I'm not sure how to update the lat and lng fields using the map click. Any help is appreciated.
Maybe one of these will work for you or at least give you some insight if you source dive.
https://filamentphp.com/plugins?search=Maps
Filament
Plugins - Filament
Community made packages for Filament projects, which give you access to awesome new features.
one thing.. looking at your step you are using ->reactive(), in filament v3 use ->live() instead. reactive was v1 and v2 I believe