Make specific fields readonly in edit mode

I want to make some fields readonly in edit mode. What is the correct approach to do that? Currently I am setting editable false in onInit event and true in onInitEntity event, this way fields are these fields are editable in create mode only.


Please set in screen descriptor for the field editable - false (use Component Inspector or add attribute to xml tag editable="false")

And, as you did, add the onInitEntity event. Then inject the field into the screen controller, and set editable-true. For example:

    private TextField<String> nameField;

    public void onInitEntity(InitEntityEvent<NewEntity> event) {

After that, all calls to the edit screen, except for creating a new entity, make the attribute unavailable for editing.


1 Like

Thanks Vera. This is the right approach :+1: