How do I set a field to the ‘readonly’ state?


Step-by-step guide

  1. Click on Modules.
  2. Select the Module with the appropriate form field.
  3. Select Forms tab.
  4. Select Field List button "Create/Update Fields".
  5. User filter to find field that is intended to be made readonly.
  6. Select edit on the field.
  7. Select Cutsom JavaScript tab.
  8. Within the “init” section type:

if (formScope.formdata["state"].toUpperCase() === 'Initial'.toUpperCase()) {

fieldScope.fieldSchema.readOnly = true;

fieldScope.readOnly = true;

}

9.  Select Update.

10. Select Save for the form.


Note: This example sets the field to read only based on the “Initial” state condition. If you wish to change it in a different state, this may be edited to the current state appropriate to where it is implemented . For example, if a form is set to “Initial” state you could use this condition

!== 'Initial'.toUpperCase()


To default to read only state on a form in the “Initial” state.

Or by state of “Pending”:


if (formScope.formdata["state"].toUpperCase()  === 'Pending'.toUpperCase()) {

fieldScope.fieldSchema.readOnly = true;

fieldScope.readOnly = true;

}