Sep 24 2008
How to ‘switch off’ mandatory fields when the subform they belong to becomes invisible
Disease:
Putting objects ‘visible/invisble’ is a great feature to guide end-users to fill-out forms in an easy way. However, when putting a subform, which contains mandatory fields to invisible, the mandatory fields still remain mandatory. This can off course be solved by putting all mandatory fields to ‘non-mandatory’ through scripting but can become a development nightmare.
Prescription:
The idea is to have a general procedure which would specify for each subform which fields are mandatory. We will define an array inside the form which will contain a list of mandatory fields for each subform. Secondly, a procedure is built which will loop through this array for the given subform and will put the fields to mandatory/non-mandatory depending on the fact whether the subform has been set to visible/invisble.
A sample form can be found here.
Tips to stay healthy:
When analyzing your forms take in consideration how objects will be grouped and which fields are mandatory within a group. This makes it afterwards easy to introduce these fields/subforms in the array.