This topic is locked

date createed / date updated

10/20/2005 10:57:02 AM
PHPRunner General questions
V
vandecan author

Hello,
I have solved the problem on putting a date for the field created by putting the function now().
For the updated field I do not know how to do.
Somebody have an idea ?
Thanks.
François

Sergey Kornilov admin 10/21/2005

Hi,
To fill a field with the current date you can find this line in ..._edit.php file:

$value=$data["datefield"];



and replace it with:

$value=now();



where datefield is your actual field name.

V
vandecan author 10/21/2005

Thanks for the answer.

No another question linked to change to php files.

Once we rebuild the solution, we loose all changes ?
Thanks.

Sergey Kornilov admin 10/21/2005

Yes, all changes to files will be lost after project rebuild.

hfg 3/22/2007

I am wanting to have the status_date field change automaticly to the current day everytime a record is edited and saved. This is something I used to use in version 3.0 using the method in this posting. I am finding it difficult to apply to version 3.1.
Is there a way to do this from within PHPRunner now without having to hack the code?
thanks

V
Vladimir 3/22/2007

Hi, hfg.
You can do it using Before record updated event on the Events tab. Here is a sample code:

$values["status_date"] = now();

hfg 3/22/2007

Thanks for the reply but I think I'm still missing something, I added the following code to the events. But when I go to the edit screen the date shown in Status_Date is still the perviously saved date.
Thanks for the help
My Code:
function BeforeEdit(&$values, $where)

{
// Parameters:

// $values - Array object.

// Each field on the Edit form represented as 'Field name'-'Field value' pair

// $where - string with WHERE clause pointing to record to be edited
//** Custom code ****

// put your custom code here
$values["Status_Date"] = now();
return true;
// return true if you like to proceed with editing this record

// return false in other case
}

J
Jane 3/22/2007

Hi,
status_date field will be updated when you save this record.

If you want to update this field before opening EDIT page use EditOnLoad event:

function EditOnLoad()

{

global $smarty;

$smarty->assign("value_status_date",now());

}

hfg 3/23/2007

That did the job, thanks