We define an editor and its fields with the full functionality by default.
In our context a logged in user has a particular role and should be able to see or use a subset of the form based on its role and the editor mode (edit, new, delete).
A typical case is to change some writable fields to readonly or hide them. The role is given in JS through a variable.
So what would be the best approach to change an editor instance and its field definition before each edit/new/search invocation based some code for implementing the necessary changes to the field definition?