Metadata Schema: TagField - Is there a way to add properties for "forceSelection" from UI Metadata Schema end? | Community
Skip to main content
Level 2
June 16, 2023
Solved

Metadata Schema: TagField - Is there a way to add properties for "forceSelection" from UI Metadata Schema end?

  • June 16, 2023
  • 1 reply
  • 597 views

Hi,

 

Is there an option to add the "forceSelection" field for the tagfield resourceType through the Metadata Schema from UI end?

 

This is how it should appear for the tagfield in the crx/de backend.

 

- 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,

This is possible, here are detailed instructions:

  1. Overlay /libs/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/v2/tagsfield/tagsfield.jsp, so as a result you will get structure under apps:/apps/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/v2/tagsfield/tagsfield.jsp
  2. Edit tagsfield.jsp under overlay, and add below code:
    <% boolean forceSelection = cfg.get("forceSelection", false); String forceSelectionChecked = forceSelection ? "checked" : ""; %> <input handle="input" type="checkbox" name="<%= xssAPI.encodeForHTMLAttr("./items/" + key + "/forceSelection") %>" value="true" <%= forceSelectionChecked %>/> <input type="hidden" name="<%= xssAPI.encodeForHTMLAttr("./items/" + key + "/forceSelection@TypeHint") %>" value="Boolean"/> <label for="forceSelection">Force Selection</label><br>

     

The result will look like this:

Additionally you can experiment with styling to make it look like other checkboxes.

 

1 reply

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

Hi @anish11,

This is possible, here are detailed instructions:

  1. Overlay /libs/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/v2/tagsfield/tagsfield.jsp, so as a result you will get structure under apps:/apps/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/v2/tagsfield/tagsfield.jsp
  2. Edit tagsfield.jsp under overlay, and add below code:
    <% boolean forceSelection = cfg.get("forceSelection", false); String forceSelectionChecked = forceSelection ? "checked" : ""; %> <input handle="input" type="checkbox" name="<%= xssAPI.encodeForHTMLAttr("./items/" + key + "/forceSelection") %>" value="true" <%= forceSelectionChecked %>/> <input type="hidden" name="<%= xssAPI.encodeForHTMLAttr("./items/" + key + "/forceSelection@TypeHint") %>" value="Boolean"/> <label for="forceSelection">Force Selection</label><br>

     

The result will look like this:

Additionally you can experiment with styling to make it look like other checkboxes.