From 1914ee176eda404fee8452d0cd423cd029a5c019 Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Wed, 15 Apr 2020 14:49:10 +0200 Subject: [PATCH 1/3] Get correct field value depending on localization settings --- templates/content/_fields.html.twig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/content/_fields.html.twig b/templates/content/_fields.html.twig index 9e7fb42a0..50044e359 100644 --- a/templates/content/_fields.html.twig +++ b/templates/content/_fields.html.twig @@ -4,7 +4,14 @@ aria-labelledby="{{ group|slug }}-tab"> {% for key, fielddefinition in record.definition.fields|filter(fielddefinition => fielddefinition.group == group) %} {% if record.hasField(key) %} - {% set field = record.getField(key)|translated(currentlocale) %} + {% set field = record.getField(key) %} + {% if field.isTranslatable %} + {# If the field is translatable, we want the translated value in the current locale #} + {% set field = field|translated(currentlocale) %} + {% else %} + {# Othewise, we want the value in the default locale #} + {% set field = field|translated(field.defaultLocale) %} + {% endif %} {% else %} {% set field = field_factory(key, fielddefinition) %} {% endif %} From 32c3022169426f436c22b9be2c6723c9eb9370e9 Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Wed, 15 Apr 2020 15:00:47 +0200 Subject: [PATCH 2/3] A bit more comments --- templates/content/_fields.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/content/_fields.html.twig b/templates/content/_fields.html.twig index 50044e359..407d8af4d 100644 --- a/templates/content/_fields.html.twig +++ b/templates/content/_fields.html.twig @@ -9,7 +9,7 @@ {# If the field is translatable, we want the translated value in the current locale #} {% set field = field|translated(currentlocale) %} {% else %} - {# Othewise, we want the value in the default locale #} + {# Othewise, we want the value in the default locale, exlicitly in case it is something else #} {% set field = field|translated(field.defaultLocale) %} {% endif %} {% else %} From f8d837dcad832f5161d3c56ac473b94636379350 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 15 Apr 2020 15:23:31 +0200 Subject: [PATCH 3/3] Update templates/content/_fields.html.twig --- templates/content/_fields.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/content/_fields.html.twig b/templates/content/_fields.html.twig index 407d8af4d..b2b38eb2c 100644 --- a/templates/content/_fields.html.twig +++ b/templates/content/_fields.html.twig @@ -9,7 +9,7 @@ {# If the field is translatable, we want the translated value in the current locale #} {% set field = field|translated(currentlocale) %} {% else %} - {# Othewise, we want the value in the default locale, exlicitly in case it is something else #} + {# Otherwise, we want the value in the default locale, explicitly in case it is something else #} {% set field = field|translated(field.defaultLocale) %} {% endif %} {% else %}