How do I set a field to the ‘readonly’ state?
Step-by-step guide
Click on Modules.
Select the Module with the appropriate form field.
Select Forms tab.
Select Field List button "Create/Update Fields".
User filter to find field that is intended to be made readonly.
Select edit on the field.
Select Cutsom JavaScript tab.
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;
}