Created
May 22, 2015 07:20
-
-
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.
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
// 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