Skip to content

Commit 4ff85c8

Browse files
committed
Correct behaviour when cloned
1 parent b66891f commit 4ff85c8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/AddressFinderField.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ public function __construct($name, $title = null, $value = null)
107107
parent::__construct($name, $title, $value);
108108
}
109109

110+
/**
111+
* Clones
112+
*/
113+
public function __clone()
114+
{
115+
$this->manualFields = clone $this->manualFields;
116+
$this->addressField = clone $this->addressField;
117+
$this->manualToggle = clone $this->manualToggle;
118+
}
119+
110120
/**
111121
* @param bool $bool
112122
*
@@ -340,6 +350,15 @@ public function setValue($value, $record = null)
340350
*/
341351
public function saveInto(DataObjectInterface $record)
342352
{
353+
if (!$this->addressField->Value()) {
354+
// value hasn't been set. Load from the URL
355+
$postVars = Controller::curr()->getRequest()->requestVars();
356+
357+
if ($postVars && isset($postVars[$this->getName()])) {
358+
$this->setValue($postVars[$this->getName()]);
359+
}
360+
}
361+
343362
$record->{$this->getName()} = $this->addressField->Value();
344363

345364
if ($this->getShowManualFields()) {

0 commit comments

Comments
 (0)