This is a really great plugin, thanks mikko. However i noticed a critical proclem, that is it doesnt consider fields that are required.
Scenario:
A "conditioned" field is required, if and only if the "conditioning" field that triggered it was selected. eg, a user is required to choose the model of his car if he first selects himself as a driver
But because it was not triggered to appear, it remains irrelevant to the user, but yet when the user tries to submit, he was notified that the field is required.
The way to get around this (i assume) is to set the fields as not required in the admin backend. This is no good if the "conditioned" field is required like i mentioned.
So anyway, long story short, here's the fix:
go to conditions.php line 78-79 (or thereabouts) and replace it with:
[code:1] $ret.="\nshowHide(document.getElementsByName(prefix+'".($fields[$fieldN]->name).$fieldPostfix.
"')[0].parentNode.parentNode,node.value=='".$condition->value."' && node.checked!=false, '".$fields[$fieldN]->name.$fieldPostfix."');";
[/code:1]
and then to line 90 (or thereabouts) and replace it with:
[code:1] $init.="\nshowHide(inputs[input].parentNode.parentNode,tempObj.value=='".$condition->value."' && tempObj.checked!=false, '".$fields[$fieldN]->name.$fieldPostfix."');}";
[/code:1]
Now, go to funcs.js, search for the function showHide, and change the whole function code to this:
[code:1]function showHide(element, show, reqfield){
if (element.addEventListener){
element.style.visibility=((show)?'visible':'collapse');
document.getElementsByName(reqfield)[0].mosReq = ((show)?'1':'0');
}else{
element.style.display=((show)?'block':'none');
document.getElementsByName(reqfield)[0].mosReq = ((show)?'1':'0');
}
}
[/code:1]
After fixing these codes, your users will no longer be prompted to fill in fields that are not visible to him.
Note: this hack assumes all fields (that are visible to the user depending on his responds to "conditioning" fields) are required, so the fields must be set to required at the backend.