This topic is locked
[SOLVED]

 Add Page and Edit Page

7/11/2011 9:35:50 AM
PHPRunner General questions
I
imthebest author

I want to put a default value (random number) to a read only field when user adds a record. I made that field as Read Only, and put the default value as rand()in "Default value" option in Editor. This is working fine.
But when user wants to Edits the record, the random number (which is default in Add page) should not generate new, but should be extracted from database and should remain read only. For that I unchecked "Apply on Edit page as well" option available near Default value option on Add page. But, when user opens Edit Page, I am finding that new random number is generating. In fact, checking or unchecking the "Apply on Edit page as well" option is not making any difference in this case.
Is there any other way to generate random number, but only in case of Add New Record (not while Editing the record).
Thanks a lot.

C
cgphp 7/11/2011
  1. Remove rand() in "Default value" option in Editor and left it blank.
  2. In the "Process record values" event of the Add page paste this code:

$values['readonly_field_name'] = rand();
I
imthebest author 7/12/2011


  1. Remove rand() in "Default value" option in Editor and left it blank.
  2. In the "Process record values" event of the Add page paste this code:

$values['readonly_field_name'] = rand();



Thanks cgphp. This worked like charm.