vladan
live() removes/resets already set value
I have a map and based on the polygons selected I want to save them into a field and update the number of zip codes based of it.
I have a view
View::make('filament.forms.components.zip-code-map')->label('Territory Map'),
I want to do something like this
Forms\Components\Hidden::make('zip_code_map')->live()
->afterStateUpdated(function ($state, Forms\Set $set) use ($form) {
$set('zip_code_count', rand(1, 1000));
})
and the relevant part from the view is
function savePolygonsToStorage(polygons) {
var savedPolygons = polygons.map(function(polygon) {
var coords = polygon.getPath().getArray().map(function(coord) {
return { lat: coord.lat(), lng: coord.lng() };
});
return { id: polygon.id, name: polygon.name, coords: coords };
});
var zipCodeMapField = document.getElementById('data.zip_code_map');
if (zipCodeMapField) {
zipCodeMapField.value = JSON.stringify(savedPolygons);
zipCodeMapField.dispatchEvent(new Event('input'));
}
}
so if there's live()
attached to any of the components after afterStateUpdated
the value for zipCodeMapField.value
is reset/set to ''
and it's invalid
if live()
is not used, then the value is properly populated with a json field and properly saved after clicking save
but I can't make reactivity to work
I'm totally stumped, if this approach does not work, any other ideas?2 replies
Relations with own pages
https://filamentphp.com/docs/3.x/panels/resources/relation-managers#relation-pages
Instead of managing it all using frames, I'd like them to have separate pages
'addresses' => Pages\ManageCustomerAddresses::route('/{record}/addresses'),
something like
'addresses' => Pages\ManageCustomerAddresses::route('/{record}/addresses/{address}/edit'),
any idea how to achieve that?3 replies