OOTB checkbox is not available in AEM 6.3 metadata schema editor. But, it can be enabled and used with steps as described below.
Step 1: Overlay builditems.jsp to Enable checkbox
- Create an /apps overlay for “/libs/dam/gui/coral/components/admin/schemaforms/formbuilder/builditems.jsp“
- In “/apps/dam/gui/coral/components/admin/schemaforms/formbuilder/builditems.jsp“, uncomment the following snippet. It would be available between line 90-98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% Resource checkboxResource = formResourceManager.getCheckboxFieldResource(resource); %> | |
<li class="field" data-fieldtype="checkbox"> | |
<div class="formbuilder-template-title"><coral-icon icon="select" size="M"></coral-icon><span><%= i18n.get("Checkbox") %></span></div> | |
<script class="field-properties" type="text/x-handlebars-template"> | |
<sling:include resource="<%= checkboxResource %>" | |
resourceType="dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/checkboxfield" /> | |
</script> | |
</li> | |
At this point, browse to a metadata schema editor:
- Click on navigation rail. Browse to Tools > Assets > Metadata Schemas
- Click on default > Select edit
- Notice that checkbox is available in the menu.
Though you can currently add checkbox for a metadata schema, you will not be able to persist the checkbox state properly.
Step 2: Persisting checkbox state
- Create an /apps overlay for “/libs/dam/gui/coral/components/admin/metadataeditor/clientlibs/metadataeditor/js/form.js”
- In “/apps/dam/gui/coral/components/admin/metadataeditor/clientlibs/metadataeditor/js/form.js”, add ONLY lines 27-52 from following snippet. Please note the placement relative to an existing function “allCheckbox.each(function (index, checkbox))”
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allCheckbox = $('[data-metatype=checkbox]', $form); | |
allCheckbox.each(function (index, checkbox) { | |
var $checkbox = $(checkbox); | |
if($checkbox.is(":checked")){ | |
$checkbox.attr('value','true'); | |
} | |
// Add false to checkbox if asset is not opened in bulk metadata editor | |
// see https://jira.corp.adobe.com/browse/CQ-98699 for details . | |
// in bulk metadata editor only checked state is considered. | |
else if(!($(".foundation-collection").data("foundation-selections-mode")=="multiple")){ | |
$checkbox.attr('value','false'); | |
} | |
var typeHint = $checkbox.data('typehint'); | |
if (!typeHint) { | |
typeHint = 'Boolean'; | |
} | |
var name = $checkbox.attr('name'); | |
hintFields.push({ | |
'name': name + '@TypeHint', | |
'value': typeHint | |
}); | |
}); | |
var allMetatypeCheckbox = $('coral-checkbox[data-metatype=checkbox]', $form); | |
allMetatypeCheckbox.each(function (index, coralCheckbox) { | |
var $coralCheckbox = $(coralCheckbox); | |
var $checkbox = $coralCheckbox.find("input[type='checkbox']"); | |
if($checkbox){ | |
if($checkbox.is(":checked")){ | |
$checkbox.attr('value','true'); | |
} | |
// Add false to checkbox if asset is not opened in bulk metadata editor | |
// see https://jira.corp.adobe.com/browse/CQ-98699 for details . | |
// in bulk metadata editor only checked state is considered. | |
else if(!($(".foundation-collection").data("foundation-selections-mode")=="multiple")){ | |
$checkbox.attr('value','false'); | |
} | |
var typeHint = $checkbox.data('typehint'); | |
if (!typeHint) { | |
typeHint = 'Boolean'; | |
} | |
var name = $checkbox.attr('name'); | |
hintFields.push({ | |
'name': name + '@TypeHint', | |
'value': typeHint | |
}); | |
} | |
}); |
You should now be able to:
- Add checkbox to a metadata schema.
- Persist its checked/unchecked state for the applicable assets.