Fixes property model binding to display to show the invariant data if the property is non variant
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user