From 710fe575a6482b99d5997fe4b407922a3277b5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Hrdina?= Date: Mon, 6 Mar 2023 09:36:03 +0000 Subject: [PATCH] feat: properly support translated info collection fields --- .../RepositoryForms/InformationCollectionMapper.php | 2 +- lib/Handler.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php b/bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php index 9cb45293..e3800cfb 100644 --- a/bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php +++ b/bundle/EzPlatform/RepositoryForms/InformationCollectionMapper.php @@ -26,7 +26,7 @@ final class InformationCollectionMapper */ public function mapToFormData(Content $content, Location $location, ContentType $contentType) { - $fields = $content->getFieldsByLanguage($content->contentInfo->mainLanguageCode); + $fields = $content->getFieldsByLanguage(); $informationCollectionFields = []; diff --git a/lib/Handler.php b/lib/Handler.php index b5840d84..8168c0a0 100644 --- a/lib/Handler.php +++ b/lib/Handler.php @@ -46,8 +46,10 @@ public function getForm(Content $content, Location $location): FormInterface $data = $informationCollectionMapper->mapToFormData($content, $location, $contentType); + $initialLanguageCode = $content->getVersionInfo()->getInitialLanguage()->languageCode; + return $this->formFactory->create(InformationCollectionType::class, $data, [ - 'languageCode' => $content->contentInfo->mainLanguageCode, + 'languageCode' => $initialLanguageCode ?? $content->contentInfo->mainLanguageCode, 'mainLanguageCode' => $content->contentInfo->mainLanguageCode, ]); }