This topic is locked

How to make a field element read-only with Custom CSS in Designer

5/28/2021 6:36:08 AM
PHPRunner General questions
J
jianwong author

I made a copy of Edit page. In the new Edit page, I want some field elements to be read-only.
I can't use event code or javascripts to do it because it apply to the same fields in the default Edit page. The only way I can think of achieving it is with Custom CSS on the desired element in Designer.
Anyone has any guild on Custom CSS to share? Or any other method to achieve it, please share.
Thanks.

HJB 5/28/2021

Try the following CSS (insert name of your
field element within the curved brackets
seen on code line #2 as below):

/* Any element that is not writable */
:read-only { }

/* ... so you might want to scope it */
input:read-only,
textarea:read-only,
[contenteditable]:read-only {
cursor: not-allowed;
}

/* Any enabled text input
or enabled textarea
or element with the contenteditable attribute */
:read-write {
background: white;
cursor: text;
}
S
sthefaine 5/30/2021

Hi I believe there is an easier way to do it.

1st get the page name useing events reference this fro help guide.
https://xlinesoft.com/phprunner/docs/working-with-additional-pages.htm

2nd pass that page name to javascript using a proxy. Reference this from help guide.
https://xlinesoft.com/phprunner/docs/setproxyvalue.htm

Use an if statement in Javascript to MakeReadOnly and MakeReadWrite for the fields you want based on PageName sent via proxy.

Hope that helps.

Steve