From 40cc510057c774be004db50bccdb4d4bc4fe530a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 29 Feb 2020 14:08:11 +0100 Subject: [PATCH] Fix bad location storage. --- app/Http/Requests/Request.php | 4 +++- resources/views/v1/form/location.twig | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 0a22172e3d..d85310ff38 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -347,6 +347,7 @@ class Request extends FormRequest $longitudeKey = null === $prefix ? 'longitude' : sprintf('%s_longitude', $prefix); $latitudeKey = null === $prefix ? 'latitude' : sprintf('%s_latitude', $prefix); $zoomLevelKey = null === $prefix ? 'zoom_level' : sprintf('%s_zoom_level', $prefix); + $hasLocationKey = null === $prefix ? 'has_location' : sprintf('%s_has_location', $prefix); // for a POST (store, all fields must be present and accounted for: if ( @@ -354,7 +355,8 @@ class Request extends FormRequest && ($this->has($longitudeKey) && $this->has($latitudeKey) && $this->has($zoomLevelKey)) ) { Log::debug('Method is POST and all fields present.'); - $data['store_location'] = true; + + $data['store_location'] = $this->boolean($hasLocationKey); $data['longitude'] = '' === $this->string($longitudeKey) ? null : $this->string($longitudeKey); $data['latitude'] = '' === $this->string($latitudeKey) ? null : $this->string($latitudeKey); $data['zoom_level'] = '' === $this->string($zoomLevelKey) ? null : $this->integer($zoomLevelKey); diff --git a/resources/views/v1/form/location.twig b/resources/views/v1/form/location.twig index 625c144a35..fc05436cee 100644 --- a/resources/views/v1/form/location.twig +++ b/resources/views/v1/form/location.twig @@ -86,6 +86,7 @@ console.log('Set object location: lat(' + e.latlng.lat + '), long(' + e.latlng.lng + '), zoom (' + mymap.getZoom() + ')'); $('input[name="{{ latitudevar }}"]').val(e.latlng.lat); $('input[name="{{ longitudevar }}"]').val(e.latlng.lng); + $('input[name="{{ haslocationvar }}"]').val('true'); } if (typeof e.latlng === 'undefined') { console.log('Set object zoom level to ' + mymap.getZoom());