Taxonomy Name Value

Topics: Writing modules
Dec 26, 2013 at 3:53 PM
Hi , I was creating couple of dropdown list that will be managed from Admin side , I used the taxonomy as the golden source for my dropdown , I was just wondering if we can have a value field in the taxonmy , I know we have the ID , and the Name , but there is no Value field ! Is there a reason for that ? So what would be the best approach to populate drop down used in a module from the admin panel with Name and Value field ( and as well with Parents to be able to have optgroup ) .
So Far taxonomy is working well except that i don't have a value field . Any suggestions is more than welcome .

Thanks
Developer
Dec 26, 2013 at 7:44 PM
When I render dropdowns based on taxonomy terms, I generally use the term ID as the Value for my dropdown option items. Perhaps you can do the same? If you do need an additional field, you can add content fields to your taxonomy term content type.
Marked as answer by Ahedd on 12/27/2013 at 4:45 PM
Dec 28, 2013 at 12:49 AM
Thanks Skywalker i did added the value field , this is what i have done . For those who might need this as well
This is the migration
public int UpdateFrom3() {
            
            ContentDefinitionManager.AlterPartDefinition(
                "TermPart"
                , b => b
                    .Attachable()
                    .WithField("Value", cfg => cfg.OfType("TextField").WithDisplayName("Value")));
            return 4;
        }
This the function to create the taxonomy terms from code .
 private void CreateTaxonomyTerm(TaxonomyPart taxo, string name, string value) {
      
            var term = _taxonomyService.NewTerm(taxo);
            term.Name = name;
            _contentManager.Create(term, VersionOptions.Published);
            var field = ((dynamic)term).Value;
            field.Value = value;
        }
Thanks for the help