Skip to content

Commit

Permalink
Merge pull request #1299 from bolt/bugfix/backend-display-language
Browse files Browse the repository at this point in the history
Get correct field value depending on localization settings
  • Loading branch information
bobdenotter authored Apr 15, 2020
2 parents 331a320 + f8d837d commit 353f30e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion templates/content/_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
{# Otherwise, we want the value in the default locale, explicitly in case it is something else #}
{% set field = field|translated(field.defaultLocale) %}
{% endif %}
{% else %}
{% set field = field_factory(key, fielddefinition) %}
{% endif %}
Expand Down

0 comments on commit 353f30e

Please sign in to comment.