Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

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

Avatar

Level 2

Hi,

 

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

anish11_1-1686936814152.png

 

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

anish11_2-1686936910559.png

 

- Anish

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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
    tags-overlay.jpg
  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>

     

    jsp.jpg

The result will look like this:

tags-metadata-conf.jpg

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

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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
    tags-overlay.jpg
  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>

     

    jsp.jpg

The result will look like this:

tags-metadata-conf.jpg

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