From df8fe5b96324d1179e29e41ca992cb2a461d0256 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Thu, 7 May 2020 10:43:57 +0200 Subject: [PATCH] Fix copy translation (#63) * Fix copy translation Non translated field may not use values of fallback language. Use default value defined in the dca or the sql default instead --- src/Driver.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Driver.php b/src/Driver.php index 5f52c32..cd780f2 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -604,9 +604,15 @@ public function copy($blnDoNotRedirect = false) $set = $this->set; foreach ($objTranslations->row() as $k => $v) { - if (in_array($k, array_keys($GLOBALS['TL_DCA'][$this->strTable]['fields'])) - && $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['translatableFor'] != '' - ) { + if (array_key_exists($k, $GLOBALS['TL_DCA'][$this->strTable]['fields'])) { + if (!$GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['translatableFor']) { + if (isset($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['default'])) { + $set[$k] = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['default']; + } else { + unset($set[$k]); + } + continue; + } // Empty unique fields or add a unique identifier in copyAll mode if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$k]['eval']['unique']) { if (\Input::get('act') == 'copyAll') {