Names are wrong within Annotations.WidgetFlags


This report is actually an issue with the documentation rather than an actual ‘bug’. Basically I needed to turn all of my form fields read-only in certain situations. The documentation is a little vague on how to do this but I found it in the API. However, the API section for setting flags says to use the ‘field.flags.set(options, shouldSet)’ function, and then pass the STRING of the flag you want to set.

The names listed in your documentation are written in upper case like c-style constants READ_ONLY, except the actual names of the flags are in CamelCasing like ReadOnly. This caused a bit of frustration for me until I investigated the actual field.flags object using debug tools, then realized they are just named wrong in the docs. As you can see I’ve already figured out the solution but you will probably want to fix the documentation for this as it’s either confusing (and I missed the correct names somewhere), or is an error.

Thank you,


This code snippet is how to actually set this flag:

console.log(field.flags?.get("ReadOnly")); // output 'false'
field.flags?.set("ReadOnly", true);
console.log(field.flags?.get("ReadOnly")); // output 'true'

Hi Scott,

The READ_ONLY thing is actually a constant which equals ReadOnly.

It should be used like so

field.flags?.set(Annotations.WidgetFlags.READ_ONLY, true);