Hi,
The task is to validate each textfield found in the multifield,
<urls jcr:primaryType="cq:Widget" fieldDescription="Click the '+' to add a multiple urls.." fieldLabel="Urls (Without etxn.)" name="./Urls" xtype="multifield"> <url jcr:primaryType="cq:Widget" fieldLabel="Url" width="155" validator="function(validateValue) { console.log(validateValue); return 'Would expect this check to be invoked';}" xtype="textfield"/> </urls>
Currently it does not seem to validate the textfield, is there a work around that would get it running through the validator ?
Thanks,
Peter
Solved! Go to Solution.
Views
Replies
Total Likes
I think I solved it. I added this to my multifield node:
< listeners jcr:primaryType="nt:unstructured" beforeadd="function(list,component,index){if(index!=0){var link=list.items.item(index-1).getValue();var myObject=JSON.parse(link);if(link.text==''){CQ.Ext.Msg.show({title:'Validation Error',msg:'Link Text can not be empty!',buttons:CQ.Ext.MessageBox.OK,icon:CQ.Ext.MessageBox.ERROR});return false;}if(link.url==''){CQ.Ext.Msg.show({title:'Validation Error',msg:'URL can not be empty!',buttons:CQ.Ext.MessageBox.OK,icon:CQ.Ext.MessageBox.ERROR});return false;}}}"/>
Found the solution at http://helpx.adobe.com/adobe-cq/using/tips-tricks.html
Views
Replies
Total Likes
You can't add a validator to the multifield since the multifield widget don't really know about the underlying xtype. I think you need to add it to the child-types field config.
Edit: And that is what you have done...
Views
Replies
Total Likes
I think I solved it. I added this to my multifield node:
< listeners jcr:primaryType="nt:unstructured" beforeadd="function(list,component,index){if(index!=0){var link=list.items.item(index-1).getValue();var myObject=JSON.parse(link);if(link.text==''){CQ.Ext.Msg.show({title:'Validation Error',msg:'Link Text can not be empty!',buttons:CQ.Ext.MessageBox.OK,icon:CQ.Ext.MessageBox.ERROR});return false;}if(link.url==''){CQ.Ext.Msg.show({title:'Validation Error',msg:'URL can not be empty!',buttons:CQ.Ext.MessageBox.OK,icon:CQ.Ext.MessageBox.ERROR});return false;}}}"/>
Found the solution at http://helpx.adobe.com/adobe-cq/using/tips-tricks.html
Views
Replies
Total Likes
Yup, the listener did it's magic,
Thank you Ove !
Peter
Views
Replies
Total Likes