Configure a Required Taxonomy Field

Legacy Documentation (Taxonomy Mixin Field)

This documentation page applies to legacy Taxonomy Mixin Field. As of version 15.3, a Taxonomy field type is available in the Document Type Editor and can be used to add a required taxonomy field to a document type.



Configure a required taxonomy field in a document type so that when saving a document of that type without any categories selected, the taxonomy field is visually marked as invalid using red coloring.


A taxonomy field in a document type can be marked as required (meaning that at least one category must be selected) by adding the 'required' validator through configuration in the Console. When applying this to a default taxonomy field added using the Essentials setup application, attempting to save a document with no categories selected will cause a feedback message to be displayed only. The taxonomy field will not be highlighted in red as is usual for invalid fields in the document type editor. This page describes the additional configuration required to also highlight an invalid taxonomy field using red coloring.

Set a taxonomy field to be required 

In order to mark a taxonomy field as required, the following steps have to be taken:

  1. Configure the org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin frontend plugin.
  2. Set required validator on classifiable mixin or document type field.

1. Configure the TaxonomyPickerPlugin as frontend plugin

Although the standard way to configure a taxonomy field is to have a classifiable node with a org.hippoecm.frontend.editor.plugins.mixin.MixinLoaderPlugin below the editor:templates part of your document type, using this setup will only give a feedback message and will not show an invalidated field using red coloring.

To produce the correct validation highlighting, configure the TaxonomyPickerPlugin directly like in the example below:

    jcr:primaryType: frontend:plugin
    field: keys
    plugin.class: org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin
    taxonomy.classification.dao: service.taxonomy.dao service.taxonomy exampletaxonomy ${}.field   (or applicable layout part e.g. ${}.right.item)

2. Set 'required' validator on classifiable mixin or document type field 

Now, we need to set a required validator on the taxonomy field. We can do this on the mixin level or on the document type level.

2a. Set classifiable mixin as 'required' 

Setting the mixin hippotaxonomy:classifiable as required will make the taxonomy fields in every document type required. To do that, add a validator required here:

    jcr:primaryType: hipposysedit:field
    hipposysedit:validators: [ required ]

2b. Add a field with validator 'required' to the document type 

For setting the taxonomy field as required on document type level, add a field node below the hipposysedit:nodetype part of the type, also with a validator required.

    jcr:primaryType: hipposysedit:field
    hipposysedit:multiple: true
    hipposysedit:path: hippotaxonomy:keys
    hipposysedit:type: String
    hipposysedit:validators: [ required ]

The result 

The screenshot below, taken using the demo project, shows what a required taxonomy field will look in the CMS:

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?