Seen this post and I have a Taxonomy named "Area" that is perfectly visible from my Dashboard.
I also have a ContentType with a ContentPart that has a field of type Taxonomy with the same name "Area" :
ContentDefinitionManager.AlterPartDefinition("GolfCoursePart", p => p
//Area Taxonomy
.WithField("AreaTaxonomy", fcfg => fcfg
.OfType("TaxonomyField")
.WithDisplayName("Area")
.WithSetting("Hint", "Area this Golf Course belongs to")
.WithSetting("Taxonomy", "Area")
.WithSetting("LeavesOnly", "true")
.WithSetting("SingleChoice", "false")
.WithSetting("Required", "true"))
But there's still missing the link between the ContentPart and the Taxonomy and I have to do it through the UI. How can I do it programmatically? (not using the Dashboard??)
I don't want to use recipes to define Content Types, I could use them to define Taxonomies but not my custom ContentTypes and ContentPats
You are missing the settings' prefixes: 'TaxonomyFieldSettings'. Try the following:
ContentDefinitionManager.AlterPartDefinition("GolfCoursePart", p => p
//Area Taxonomy
.WithField("AreaTaxonomy", fcfg => fcfg
.OfType("TaxonomyField")
.WithDisplayName("Area")
// TaxonomyFieldSettings
.WithSetting("TaxonomyFieldSettings.Hint", "Area this Golf Course belongs to")
.WithSetting("TaxonomyFieldSettings.Taxonomy", "Area")
.WithSetting("TaxonomyFieldSettings.LeavesOnly", "true")
.WithSetting("TaxonomyFieldSettings.SingleChoice", "false")
.WithSetting("TaxonomyFieldSettings.Required", "true"))