for (var i in fieldsToLock) this.getField(fieldsToLock).readonly = true;
There are a lot of fields to be made read only, but there are some not shown here, which i need to stay writable. It works for about 75% of the fields but not the others. I've checked all the names are correct. What else could be causing this? And is there any way around the problem?
Note that if you use hierarchical field naming, you can control a group of field with a single statement. For example, if you had fields named "Group1.Text1", "Group1.Text2", "Group1.Fencelength", you can set them all to read-only like this: