This topic is locked
[SOLVED]

 How to make a field editable only if blank

7/12/2015 9:57:50 PM
PHPRunner General questions
S
Stucco author

Hi - I'd like to make a field that can only be edited if there is not a value already in it. This would end up always being editable on the add page and editable on the edit page if there is no value already in it.
Thanks!

S
Stucco author 7/13/2015



Hi - I'd like to make a field that can only be edited if there is not a value already in it. This would end up always being editable on the add page and editable on the edit page if there is no value already in it.
Thanks!


I found the answer here: http://www.asprunner.com/forums/topic/22912-dynamic-read-only-field-without-javascript/

N
nti 7/15/2015

Hey Stucco,
I am trying to solve the same problem without success...
Can you post your working example ?
Thank you.

S
Stucco author 7/16/2015

Hi - For mine, it was just adding the following.
'device' is my field - I added the following to Events - Before Display

if($values['device'] != "") {

$xt->assign('device_editcontrol',$values['device']);

}


You may want to do some trim or something before checking if it is empty in case your users are in the habit of saving fields with only whitespace.

N
nti 7/27/2015

Thank you, Stucco
Your code snippet gave me insight.
This worked for me. This snippet hides the TaxCounty field.



if ($values["TaxCounty"] !== '0')

$pageObject->hideField("TaxCounty");


'TaxCounty' is fieldname
below also worked great.



if($values['TaxCounty'] != "0") {

$xt->assign('TaxCounty_editcontrol',$values['TaxCounty']);

}


Version: e8.0 v23504_x86