Form field deactivation

The form fields bound to a dialog are by default active (they can get the focus). When needed, disable the fields that do not require user input, and reactivate them later during the dialog execution.

For example, imagine a form containing an "Industry" COMBOBOX field , with the options Healthcare, Education, Government, Manufacturing, and Other. If the user selects "Other", a secondary EDIT field is expected to be activated automatically, to let the user input the specific description of the industry. But if one of the predefined values is selected, there is no need for the additional field, so the secondary field can be left disabled.

This can be achieved by enabling/disabling fields with the ui.Dialog.setFieldActive() method depending on the context. The "Industry" field case described can be implemented as follows:
   INPUT BY NAME rec.*
      ON CHANGE industry 
         -- A value of 99 corresponds to the "Other" item 
         CALL DIALOG.setFieldActive( "cust.industry", (rec.industry!=99) )
     CALL DIALOG.setFieldActive( "cust.industry", FALSE )

Consider centralizing field activation / deactivation in a setup function specific to the dialog, passing the DIALOG object as parameter.

Do not disable all fields of a dialog, otherwise the dialog execution stops (at least one field must get the focus during a dialog execution).

If you disable the current field having the focus, the dialog will execute the AFTER FIELD block of the current field and the BEFORE FIELD block on the next field in the tabbing order. This can unnecessarily fire validation code implemented in AFTER FIELD. As a general pattern, do not disable the current field having the focus.

Note: Form fields can be hidden with the ui.Form.setFieldHidden() method of the form objects. A dialog considers hidden fields as disabled (there is no need to disable fields that are already hidden).