Set/Remove "read-only" status for form fields

stryker129
Mega Guru

As per my requirements I need to open existing record and disable (set "read-only" to true) all form fields.

Also there should be a button on a form which will enable (set "read-only" to false) all form fields.

I did the following:

1. Created client script that disable existing record: Gyazo - 49fb5bd9c0765865b27e304a7acd5343.png - it works fine

2. Created form button and add action: Gyazo - f1247f0b2aa73bdc99d201080434aff7.png   - but it doesn't work: when I click this button - nothing happens - but it will enable all form fields for editing

Please advice where I am wrong?

Debugger doesn't stop in onClick() function

6 REPLIES 6

Nana5
Mega Guru

Hi


Please try with the below code:



function onLoad(){


var fields = g_form.getEditableFields();  


for (var x = 0; x < fields.length; x++) {  


g_form.setReadOnly(fields[x], true);  


}


}



Thanks


Doesn't work.


I need it on onClick, not on onLoad.


HI


I think u need to use onclick event.Please find the example:


buttonRef.addEventListener("click", function() {


var fields = g_form.getEditableFields();


for (var x = 0; x < fields.length; x++) {


g_form.setReadOnly(fields[x], true);


}



}, false);




Thanks



Where should I use it? In editing UI action?


Gyazo - b9d42767695c183bc0e1620091941248.png


Thanks