How to Access Updated Latitude and Longitude in beforeSave in Filament?
I want to validate the newly input latitude and longitude in Filament before saving the data to the database, using the beforeSave lifecycle method. However, I'm having trouble ensuring that the updated values entered in the form are available in beforeSave. When I dd the data, the latitude and longitude seem to be missing or reflect old values.
How can I ensure that the latest latitude and longitude values from the form are properly sent and accessible in beforeSave? Has anyone encountered a similar issue?
6 Replies
There is no way to help you from this. We have no idea what any of these custom fields are doing.
Thanks for the reply. Latitude and longitude are updated successfully using Map::make() and afterStateUpdated. However, when I use dd() in beforeSave, the data from address, lat, and lng is not available. Any suggestions on ensuring this data is available in beforeSave?
There’s no way to give advice without see the code for the custom fields.
Map::make('location') code?
The full code looks like this
and I want to show lat and lng data in beforeSave here
Honestly sounds like you’re missing a ->live() somewhere.
But what is map, does it have any inputs that would trigger a state change?
Seems like you should be setting map from other fields instead of setting map from itself.
please ask in #google-maps as this pertains to that plugin