Menu
SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: Set readonly property of fields based on other field

Set readonly property of fields based on other field 2 months 3 days ago #82080

  • bf.ts90
  • bf.ts90's Avatar
  • Offline
  • Junior Member
  • Posts: 21
  • Thank you received: 1
  • Karma: 0
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.

B.
The administrator has disabled public write access.

Set readonly property of fields based on other field 2 months 3 days ago #82083

  • hoasenvang7799
  • hoasenvang7799's Avatar
  • Offline
  • Senior Member
  • I want a banana
  • Posts: 53
  • Thank you received: 4
  • Karma: 0
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.
Enjoy and passionate Open Source
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 3 weeks ago #82569

  • bf.ts90
  • bf.ts90's Avatar
  • Offline
  • Junior Member
  • Posts: 21
  • Thank you received: 1
  • Karma: 0
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.
B.
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 3 weeks ago #82571

  • Babacar
  • Babacar's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
First time include javascript file in your editview,
In your javascript file write this
$('#custom field').change(function(){
    console.log("marche");
    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');
    }
});
The administrator has disabled public write access.
The following user(s) said Thank You: bf.ts90

Set readonly property of fields based on other field 1 month 2 weeks ago #82708

  • bf.ts90
  • bf.ts90's Avatar
  • Offline
  • Junior Member
  • Posts: 21
  • Thank you received: 1
  • Karma: 0
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.

B.
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 4 days ago #83273

  • jrawoot
  • jrawoot's Avatar
  • Offline
  • Junior Member
  • Posts: 33
  • Thank you received: 2
  • Karma: 0
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.
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 4 days ago #83290

  • japio
  • japio's Avatar
  • Offline
  • Senior Member
  • Posts: 58
  • Thank you received: 6
  • Karma: 0
Have a look at the add-in dynamic-panels from the store. This enables exactly what you need.
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 4 days ago #83302

  • bf.ts90
  • bf.ts90's Avatar
  • Offline
  • Junior Member
  • Posts: 21
  • Thank you received: 1
  • Karma: 0
Hi jrawoot,
I used this instruction to make select readonly:
$('#account_type').prop('disabled', setReadonly).css('background-color',bck_color);

Hope it helps you,
B.
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 3 days ago #83353

  • jrawoot
  • jrawoot's Avatar
  • Offline
  • Junior Member
  • Posts: 33
  • Thank you received: 2
  • Karma: 0
Hello bf.ts90.
it is not working for me
giving following error: Uncaught ReferenceError: setReadonly is not defined
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 3 days ago #83356

  • bf.ts90
  • bf.ts90's Avatar
  • Offline
  • Junior Member
  • Posts: 21
  • Thank you received: 1
  • Karma: 0
Hi,
sorry, setReadonly for me is a boolean variable.

substitute setReadonly with true and it works.

B
The administrator has disabled public write access.

Set readonly property of fields based on other field 1 month 3 days ago #83358

  • jrawoot
  • jrawoot's Avatar
  • Offline
  • Junior Member
  • Posts: 33
  • Thank you received: 2
  • Karma: 0
Hello bf.ts90.
Thanks for quick reply.
It works but after submitting form value will be not submit to server.

Thanks
The administrator has disabled public write access.
Time to create page: 0.038 seconds
Powered by Kunena Forum