Umbraco 10: Need to keep underscore character in document type property when we create document type from code.
I am using Umbraco 10.
I am trying to create Document types from code. I noticed that whenever the property alias is having underscore ("_") character in it's Alias, it is getting removed. For some reason we need to keep the underscore character in it.
Here is sample piece of code that I am using (for testing purpose the code is placed in a template/razor view) -
When debugging, it is noticed that after assigning the value to Alias, Umbraco is cleaning up the value and removing the underscore character.
This is due to PropertyType.cs class in umbraco does the cleaning for Alias value.
We need to override this default behavior but not able to do so. In above example tried with providing CleanString type in configuration but not works.
Will be great help if you have any solution to above scenario.
Umbraco 10: Need to keep underscore character in document type property when we create document type from code.
I am using Umbraco 10.
I am trying to create Document types from code. I noticed that whenever the property alias is having underscore ("_") character in it's Alias, it is getting removed. For some reason we need to keep the underscore character in it. Here is sample piece of code that I am using (for testing purpose the code is placed in a template/razor view) -
When debugging, it is noticed that after assigning the value to Alias, Umbraco is cleaning up the value and removing the underscore character. This is due to PropertyType.cs class in umbraco does the cleaning for Alias value. We need to override this default behavior but not able to do so. In above example tried with providing CleanString type in configuration but not works.
Will be great help if you have any solution to above scenario.
Thanks.
We are able to resolve the issue. Here is the updated code
Here some changes are made for configuration. For this referred the code from GitHub.
https://github.com/umbraco/Umbraco-CMS/blob/v9/contrib/src/Umbraco.Core/Strings/DefaultShortStringHelperConfig.cs
If anyone has any other link for detailed documentation on this will be more helpful in understanding the behavior.
For now, we are able to create the property with alias containing underscore character.
is working on a reply...