I'm currently working on a AEM component that include custom multiefield and I have faced a problem I don't know how to solve it. I have created a custom widget for this which allows to include multiefield in multiefield. From the documentation read, as I understood there's no default configuration to this for widgets API config.
My dialog nodes:
<questions
jcr:primaryType="cq:Widget"
xtype="panel"
title="Questions">
<items jcr:primaryType="cq:WidgetCollection">
<quiz-data
jcr:primaryType="cq:Widget"
fieldDescription="Click the '+' to add a new data"
fieldLabel="Quiz"
name="./quizData"
xtype="multifield">
<fieldConfig
jcr:primaryType="cq:Widget"
xtype="apps.mypath.widgets.MultieField"/>
</quiz-data>
</items>
</questions>
The widget is working fine, except I want to set a minimum required multiefields and a maximum. I have found on the web a example, but I don't really understand how to do it, take a look at the code bellow:
myNamespace = {};
myNamespace.myCustomFunction = function (dialog) {
var isValid = function () {
var valStatus = true;
... custom JavaScript/jQuery to check if 3 items exist ...
return valStatus;
};
if (!isValid()) {
CQ.Ext.Msg.show({title: 'Validation Error', msg: 'Must contain at least 3 items!', buttons: CQ.Ext.MessageBox.OK, icon: CQ.Ext.MessageBox.ERROR});
return false;
} else {
return true;
}
}
Would be great, if someone can explain how can I achieve this for my custom multiefield, or any other ideas? Let me know if you have any questions.