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

Created by Joshua Miller, Modified on Sun, 23 Mar at 7:37 PM by Joshua Miller

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;

}


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article