Making related field readOnly

I see how to use element.field.readOnly = true but how do do that with a related field. I tried the following and it did not work.

job_master_to_job_contact.first_name.readOnly = true;

This of course did not work. Any suggestions?

elyod_72:
I see how to use element.field.readOnly = true but how do do that with a related field. I tried the following and it did not work.

job_master_to_job_contact.first_name.readOnly = true;

This of course did not work. Any suggestions?

Try to fill the property name of the related field and access it using the elements node in the Editor.

You are referring to the DATA by using:

relation.fieldName

You want to refer to the OBJECT that is displaying the data (i.e. the field on the form):

elements.fieldName.readOnly = true

To be able to reference the field object in a method - you have to fill out the “name” property as Riccardino said.