-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Which Umbraco version are you using?
13.9.2
Bug summary
When I create a property type programmatically using ValueStorageType.Integer
, the property is using Label (decimal), but I would expect Label (integer). There's another ValueStorageType.Decimal
intended for Label (decimal).
Consider the following example inspired from https://skrift.io/issues/working-with-content-types-and-data-types-programmatically/
if (!ctCourse.PropertyTypeExists("courseId"))
{
// Initialize a new tab
var propertyGroup = new PropertyGroup(false)
{
Alias = "info",
Name = "Information",
Type = PropertyGroupType.Tab,
SortOrder = 1
};
var propertyType = new PropertyType(_shortStringHelper, Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer)
{
Alias = "courseId",
Name = "Course ID",
Description = "The reference of the course.",
Mandatory = true,
SortOrder = 1,
};
propertyGroup.PropertyTypes!.Add(propertyType);
// Add the tab to the content type
ctCourse.PropertyGroups.Add(propertyGroup);
}
_contentTypeService.Save(ctCourse);


I tried explicit to assign LabelIntGuid
, but didn't seem to make a difference.
var propertyType = new PropertyType(_shortStringHelper, Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer)
{
Alias = "courseId",
Name = "Course ID",
Description = "The reference of the course.",
Mandatory = true,
SortOrder = 1,
DataTypeKey = Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelIntGuid
};
It works if I set DataTypeId
instead.
var propertyType = new PropertyType(_shortStringHelper, Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer)
{
Alias = "courseId",
Name = "Course ID",
Description = "The reference of the course.",
Mandatory = true,
SortOrder = 1,
DataTypeId = Umbraco.Cms.Core.Constants.DataTypes.LabelInt,
//DataTypeKey = Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelIntGuid,
};
or both, but setting DataTypeKey
only doesn't have any impact on this:
var propertyType = new PropertyType(_shortStringHelper, Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Label, ValueStorageType.Integer)
{
Alias = "courseId",
Name = "Course ID",
Description = "The reference of the course.",
Mandatory = true,
SortOrder = 1,
DataTypeId = Umbraco.Cms.Core.Constants.DataTypes.LabelInt,
DataTypeKey = Umbraco.Cms.Core.Constants.DataTypes.Guids.LabelIntGuid,
};

Alternatively it can of course use the overload method of PropertyType()
and pass in the specific IDataType
instance.
However it isn't really needed to fetch datatype here as these are locked and referenced in core as well.
Specifics
No response
Steps to reproduce
Use the code example above.
Expected result / actual result
I would expect ValueStorageType
to be respected and use the proper Label datatype matching value type as the other way around here: https://github.com/umbraco/Umbraco-CMS/blob/543b644ed19112ab8b401679579485522a9e05df/src/Umbraco.Core/PropertyEditors/ValueTypes.cs#L87C18-L91