From 1f570e9d883e2754d3ca4a6aa4881d62ef0c77f9 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 23 Mar 2021 16:27:37 +1300 Subject: [PATCH] BUG Fix issue with Security link being wrong fixes #689 --- src/Model/RecordLocale.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Model/RecordLocale.php b/src/Model/RecordLocale.php index ecc0f540..5d207191 100644 --- a/src/Model/RecordLocale.php +++ b/src/Model/RecordLocale.php @@ -80,15 +80,18 @@ public function getRecord() return $this->record ?: null; } - // If record isn't saved, use draft record - if (!$this->originalRecord->isInDB()) { - return $this->originalRecord; + // If record isn't saved, clone the draft record, but mark it + // as belonging to the current locale + $originalRecord = $this->getOriginalRecord(); + if (!$originalRecord->isInDB()) { + $localeRecord = clone $originalRecord; + $localeRecord->setSourceQueryParam('Fluent.Locale', $this->getLocale()); + return $localeRecord; } // Reload localised record in the corret locale - $record = FluentState::singleton()->withState(function (FluentState $newState) { + $record = FluentState::singleton()->withState(function (FluentState $newState) use ($originalRecord) { $newState->setLocale($this->getLocale()); - $originalRecord = $this->getOriginalRecord(); return $originalRecord->get()->byID($originalRecord->ID); });