Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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