Set readonly property of fields based on other field

Good morning,
for account module, I would like set some fields readonly for all users when a particular field is set (if field has a value).

Someone has my same need and has an example?
How can I implement this mechanism?

Thank you so much.


This requires a bit of knowledge about fixing .PHP files. just find them in this path …/modules/AOS_Quotes/metadata … edit files: detail_view, list_view, edit_view and add readonly = ‘readonly’ within fields you wish.

Hi, thank you for your reply,

but I would like set some fields readonly (i.g. name, industry, type, etc., but also custom fields) only if a particular field (in my case, custom field, code_c) is set.

if code_c is not set, the fields must be editable, otherwise they must be read-only.

In the path that you mentioned: ./modules/AOS_Quotes/metadata, I can’t find examples that implement this mechanism.

Have you a example code to paste here?

Thank you.

First time include javascript file in your editview,
In your javascript file write this

$('#custom field').change(function(){
    if ($('#custom field').val() == "")
        $('#field_to_put_readonly').prop('readonly', true).css('background-color','#dcdcdc');

    else {
        $('#ield_to_put_readonly').prop('readonly', false).css('background-color','#416f81');
1 Like

Thank you very much Babacar.

In my case, custom field is a readonly property because is set by background script. I put all code into $(document).ready and it works.


Hello Babacar,
Is it work fine for text field. But what about select field.
If I set disabled to select field it will not submit to server.

I want to make “select” field readonly which is depend on another field.

Have a look at the add-in dynamic-panels from the store. This enables exactly what you need.

Hi jrawoot,
I used this instruction to make select readonly:

$('#account_type').prop('disabled', setReadonly).css('background-color',bck_color);

Hope it helps you,

Hello bf.ts90.
it is not working for me
giving following error: Uncaught ReferenceError: setReadonly is not defined

sorry, setReadonly for me is a boolean variable.

substitute setReadonly with true and it works.


Hello bf.ts90.
Thanks for quick reply.
It works but after submitting form value will be not submit to server.