Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
The TaxonomyFieldDisplayDriver.Edit method ignores the TaxonomyContentItemId value for TaxonomyField properties.
To Reproduce
Steps to reproduce the behavior:
Create a ContentPart with a TaxonomyField property named Category.
public class MyContentItem : ContentPart
{
public TaxonomyField Category { get; set; }
}
Create an instance of the ContentType and alter it to use a different TaxonomyContentItemId value than the TaxonomyFieldSettings value and call the BuildEditorAsync method like the following:
var categoryTaxonomyField = new TaxonomyField() { TaxonomyContentItemId = "NotTheIDFromTheSettingsInstance" };
contentItem.Alter<MyContentItem>("MyContentItem", response =>
{
response.Category = categoryTaxonomyField;
});
var model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, true);
The TaxonomyFieldDisplayDriver doesn't respect the value I've set prior to calling BuildEditorAsync.
Expected behavior
The BuildEditorAsync call should use the TaxonomyContentItmeId value I've set prior to using the settings value.
As a workaround I've created a new Editor Option named "Settable" and updated my ContentType to use this Editor with the following services configuration, but this also doesn't work and displays two editors for the field.
The workaround wasn't working because "OrchardCore.Taxonomies" wasn't included in my manifest as a dependency. However, I think the original bug I reported should be reviewed.
Describe the bug
The TaxonomyFieldDisplayDriver.Edit method ignores the TaxonomyContentItemId value for TaxonomyField properties.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The BuildEditorAsync call should use the TaxonomyContentItmeId value I've set prior to using the settings value.
As a workaround I've created a new Editor Option named "Settable" and updated my ContentType to use this Editor with the following services configuration, but this also doesn't work and displays two editors for the field.
Following is the Custom DisplayDriver that will satisfy my needs.