This topic is locked

Make all fields read-only

2/26/2018 5:09:55 PM
PHPRunner General questions
I
infotech author

I have a 'clients' table where I would like to make all controls read-only if the "Active" value in the record is "No".

The Yes/No field is actually a "dead-man's trigger' of-sorts where the average app 'user' should not be able to change the record once the value is "No".
While I can successfully make an individual control read-only

using the Javascript OnLoad event for my Edit page:

var ctrlACT = Runner.getControl(pageid, 'Active');



if(ctrlACT.getValue() == "No")

ctrlACT.makeReadonly();



and subsequently selectively makeReadOnly other controls:
I am struggling to set all controls to read-only (even without a conditional if =statement).
I stumbled around the help pages and found reference to making fields required and tried to 'adapt' the code to my needs:

var recCtrlsArr = Runner.controls.ControlManager.getAt('clients');
for(var i=0;i<recCtrlsArr.length;i++)

{

var ctrl = recCtrlsArr[i];

ctrl.makeReadOnly();

}


However, this code has no effect, no error:
Am I on the wrong track?
..{wonk}

jadachDevClub member 2/26/2018
I
infotech author 2/27/2018

[indent]>

You need to use set proxy value

https://xlinesoft.com/phprunner/docs/setproxyvalue.htm

[/indent]
Thanks jadach,
However, I am not trying to change the variable at OnLoad, I only want to iterate through the controls and make them read-only.

By iterating through the controls, I will not have to re-code the app every time we change/add a field in the db.
setProxyVal:
[indent][indent][/indent][/indent]"Sets the variable to the given value."

Actually, I have a need for this already - I worked around it differently using $_session vars and sql lookups.

setProxyVal will come in handy, especially $pageObject->setProxyValue("master",$pageObject->getMasterRecord())
I came across your YouTube videos researching this setProxyValue - thanks for making those. Good stuff!

(my PHPRunner ver ent 9.8 build 29967 x64) throws "undefined function" when trying to SetProxyValue in Before Display event. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=84492&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
I'll keep working at it. Thanks for the direction. This is a side-project, so I will follow-up when I can get back to it.
--{wonk}