Is there a way to restrict the typed value for the Metadata Field with tagfield resourceType? | Community
Skip to main content
Level 2
June 12, 2023
Solved

Is there a way to restrict the typed value for the Metadata Field with tagfield resourceType?

  • June 12, 2023
  • 2 replies
  • 930 views

Hi,

 

Is there a way to restrict the users from having hand-typed values for the field with tagfield resourceType?

 

As shown below in the screenshot, the value for the Tags field has two values. "Typed" is the value being hand-typed whereas "Asset Properties: Orientation / Landscape" is the value being selected from the tags screen after clicking the check mark button.

In the below screenshot, I would like to restrict "Typed" value and allow the selected "Asset Properties: Orientation / Landscape" value.

 

-Anish

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

Hi @anish11,

In general you can't do this from GUI. However this can be done other way.

First of all Tags filed is using cq/gui/components/coral/common/form/tagfield, which provides below property, that could be useful in your case.

  • forceSelection by default this property is not set, which means that author can either select or enter value

    You can find full implementation under /libs/cq/gui/components/coral/common/form/tagfield/render.jsp

How you can utilize above in your scenario. Assuming you are using OOTB asset schema but it will be similar if you have custom one), you will needed to edit default schema and save it, no changes are required. As a result under /conf proper definition representing default schema will be created. To be more precise you will find it under /conf/global/settings/dam/adminui-extension/metadataschema/default, next you have to look for node that represents Tags input and add forceSelection property with value true.

That's all, from now user will be able only to select tags, and even if he/she will type value it will not be saved as a tag.

2 replies

DPrakashRaj
Community Advisor
Community Advisor
June 13, 2023

You can only control the rootpath to allow selection inside certain paths using rootpath property using docs https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/components/coral/foundation/picker/index.htmland if your use case is to only allow one as default you can use metadata profile available for asset metadata  https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/manage/metadata-profiles.html?lang=en

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
June 13, 2023

Hi @anish11,

In general you can't do this from GUI. However this can be done other way.

First of all Tags filed is using cq/gui/components/coral/common/form/tagfield, which provides below property, that could be useful in your case.

  • forceSelection by default this property is not set, which means that author can either select or enter value

    You can find full implementation under /libs/cq/gui/components/coral/common/form/tagfield/render.jsp

How you can utilize above in your scenario. Assuming you are using OOTB asset schema but it will be similar if you have custom one), you will needed to edit default schema and save it, no changes are required. As a result under /conf proper definition representing default schema will be created. To be more precise you will find it under /conf/global/settings/dam/adminui-extension/metadataschema/default, next you have to look for node that represents Tags input and add forceSelection property with value true.

That's all, from now user will be able only to select tags, and even if he/she will type value it will not be saved as a tag.

anish11Author
Level 2
June 13, 2023

Thanks @lukasz-m. This exactly solved my use case.

Also do you mind sharing the link for the online documentation on the tagfield that you have mentioned under /libs/cq/gui/components/coral/common/form/tagfield/render.jsp please?