After selecting any item within a container how do you make all items within the same container required when user tries to save DCR.Any help is greatly appreciated.Thanks.
You need to put a formAPI code on all of the items change event. Once captured, you can put all others as required.HTH
function init(){ IWEventRegistry.addItemHandler("/featuredimagegroup/featuredimage/x","onItemChange",imageSize); IWEventRegistry.addItemHandler("/featuredimagegroup/featuredimage/y","onItemChange",imageSize); IWEventRegistry.addItemHandler("/featuredimagegroup/featuredimage/radius","onItemChange",imageSize);}function imageSize(item){ var x = IWDatacapture.getItem(item.getName() + "/../x"); var xval = x.getValue(); var y = IWDatacapture.getItem(item.getName() + "/../y"); var yval = y.getValue(); var radius = IWDatacapture.getItem(item.getName() + "/../radius"); var radiusval = radius.getValue(); if (xval != "" || yval != "" || radiusval != "" ) { x.setRequired(true); y.setRequired(true); radius.setRequired(true); } }IWEventRegistry.addFormHandler("onFormInit", init);
Thanks for your reply but I need to have 9 containers that works with this code. Here is my code in the DCT file attachment.
lets try another approach, and I HIGHLY encourage you to read the manuals and attend some IWOV training:replace your code (that you put as your DCT attachment) with the following:
I do not think you can have a default(0) < the min(1).
Thanks Guys, but I need to implement as per requirement. I cannot make all required, this must be optional for other 2 items if 1 item in this container is selected. This should be effective for all 1-9 containers, not just in the 1st container. When I get it working I'll post the solution.
Well you have 2 choices. The right way is FormAPI. This should not be that hard. Your second choice is to create another container that contains X, Y and Radius. This container defaults to 0 entries and has a max of 1. If someone needs to add size, then they add to the container and fill out the required entries.
That is *certainly* wrong. coords should only have a min of 0 and a max of 1, you have a max of 9.IMHO, the parameters should be in 1 container unless you have differing counts. Here we are adding a container to get out of writing workign FormAPI. The container is not needed. Now, that being said, it is certainly an easy approach, which is why I suggested it. Andy
function init(){ IWEventRegistry.addItemHandler("/featuredimagegroup/featuredimage/x","onItemChange",imageSize); IWEventRegistry.addItemHandler("/featuredimagegroup/featuredimage/y","onItemChange",imageSize); IWEventRegistry.addItemHandler("/featuredimagegroup/featuredimage/radius","onItemChange",imageSize); if (IWDCRInfo.getDCRName() != ""){ recheckOnEdit('/featuredimagegroup'); } }function imageSize(item){ var x = IWDatacapture.getItem(item.getName() + "/../x"); var xval = x.getValue(); var y = IWDatacapture.getItem(item.getName() + "/../y"); var yval = y.getValue(); var radius = IWDatacapture.getItem(item.getName() + "/../radius"); var radiusval = radius.getValue(); if (xval != "" || yval != "" || radiusval != "" ) { x.setRequired(true); y.setRequired(true); radius.setRequired(true); } else { x.setRequired(false); y.setRequired(false); radius.setRequired(false); }}function recheckOnEdit(val){ var item = IWDatacapture.getItem(val); var itemArray = item.getChildren(); for (var imageItem=0; imageItem<itemArray.length; imageItem++) { imageSize(IWDatacapture.getItem(itemArray[imageItem].getName()+'/x')); }}IWEventRegistry.addFormHandler("onFormInit", init);