I need to have a checkbox item with two options (Yes, No). I want to hide the No option. If the user does not select the Yes option, then FormAPI will select the hidden No option when the DCR is saved.
The following code is not working:
<item name="Flag">
<checkbox>
<option value="YES" label=""/>
<hidden><option value="NO" label=""/></hidden>
</checkbox>
</item>
the following snippet is from my FormAPI code:
function init(){
IWEventRegistry.addFormHandler("onSave", SaveForm);
}
function SaveForm(){
var flagItem = IWDatacapture.getItem("Flag");
if (flagItem.getValue() == "")
{
var myArray = new Array(1);
flagItem.setValue(myArray);
}
return true;
}
I have noticed that if I use var myArray = new Array(0,1) then at least a value is saved in the Flag item, albeit the wrong value. When I use a single value in the array, as shown in the code snippet above, the checkbox item is set to null.