Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save floriankraft/ae07ae886d46def4e45f to your computer and use it in GitHub Desktop.
Save floriankraft/ae07ae886d46def4e45f to your computer and use it in GitHub Desktop.
Enable or disable the "mandatory" property of fields in an AEM (ExtJS) dialog.
// Can be called in (for example) a dialog by appending to a listener like "selectionchanged" (for a checkbox).
function (checkbox) { switchMandatoryFields(checkbox); }
// Enables or disables the "mandatory" property of the defined fields.
switchMandatoryFields = function(checkbox) {
"use strict";
var checkboxIsChecked = checkbox.optionItems.items[0].checked,
parentPanel = checkbox.findParentByType("tabpanel"),
firstTextfield = parentPanel.find("name", "./nameOfFirstTextfield")[0],
secondTextfield = parentPanel.find("name", "./nameOfSecondTextfield")[0];
if (checkboxIsChecked) {
if (firstTextfield !== null) {
firstTextfield.allowBlank = false;
}
if (secondTextfield !== null) {
secondTextfield.allowBlank = false;
}
} else {
if (firstTextfield !== null) {
firstTextfield.allowBlank = true;
}
if (secondTextfield !== null) {
secondTextfield.allowBlank = true;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment