From 8642a52a12f5921c67a522359f1ebea26d9b0ee2 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 9 May 2018 14:35:23 +1000 Subject: [PATCH] Fixes property model binding to display to show the invariant data if the property is non variant --- .../Mapping/ContentPropertyBasicConverter.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs index b5070ae8ad..327324aa10 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs @@ -44,14 +44,6 @@ namespace Umbraco.Web.Models.Mapping new NullReferenceException("The property editor with alias " + property.PropertyType.PropertyEditorAlias + " does not exist")); editor = _propertyEditors[Constants.PropertyEditors.Aliases.NoEdit]; - } - - var culture = context.GetCulture(); - - if (culture == null && property.PropertyType.Variations == ContentVariation.CultureNeutral) - { - //a language Id needs to be set for a property type that can be varried by language - throw new InvalidOperationException($"No languageId found in mapping operation when one is required for the culture neutral property type {property.PropertyType.Alias}"); } var result = new TDestination @@ -72,6 +64,15 @@ namespace Umbraco.Web.Models.Mapping return result; } } + + var culture = context.GetCulture(); + + //a culture needs to be in the context for a property type that can vary + if (culture == null && property.PropertyType.Variations.Has(ContentVariation.CultureNeutral)) + throw new InvalidOperationException($"No languageId found in mapping operation when one is required for the culture neutral property type {property.PropertyType.Alias}"); + + //set the culture to null if it's an invariant property type + culture = !property.PropertyType.Variations.Has(ContentVariation.CultureNeutral) ? null : culture; // if no 'IncludeProperties' were specified or this property is set to be included - we will map the value and return. result.Value = editor.GetValueEditor().ToEditor(property, DataTypeService, culture);