Skip to content

Commit 1cbee1c

Browse files
committed
Improve the behavior of GoogleMapsFormField
1 parent b6724fb commit 1cbee1c

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

wcfsetup/install/files/lib/system/form/builder/field/GoogleMapsFormField.class.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace wcf\system\form\builder\field;
44

5+
use wcf\data\IStorableObject;
56
use wcf\system\form\builder\data\processor\CustomFormDataProcessor;
67
use wcf\system\form\builder\IFormDocument;
78

@@ -90,10 +91,8 @@ public function populate()
9091
'coordinates',
9192
function (IFormDocument $document, array $parameters) {
9293
if ($this->getValue()) {
93-
$parameters[$this->getPrefixedId() . '_coordinates'] = [
94-
'latitude' => $this->getLatitude(),
95-
'longitude' => $this->getLongitude(),
96-
];
94+
$parameters[$this->getObjectProperty() . '_latitude'] = $this->getLatitude();
95+
$parameters[$this->getObjectProperty() . '_longitude'] = $this->getLongitude();
9796
}
9897

9998
return $parameters;
@@ -120,4 +119,25 @@ public function coordinates(float $latitude, float $longitude): static
120119

121120
return $this;
122121
}
122+
123+
#[\Override]
124+
public function updatedObject(array $data, IStorableObject $object, $loadValues = true): static
125+
{
126+
if ($this->isImmutable()) {
127+
$loadValues = true;
128+
}
129+
130+
if (
131+
$loadValues
132+
&& isset($data[$this->getObjectProperty() . '_latitude'])
133+
&& isset($data[$this->getObjectProperty() . '_longitude'])
134+
) {
135+
$this->coordinates(
136+
$data[$this->getObjectProperty() . '_latitude'],
137+
$data[$this->getObjectProperty() . '_longitude']
138+
);
139+
}
140+
141+
return parent::updatedObject($data, $object, $loadValues);
142+
}
123143
}

0 commit comments

Comments
 (0)