This topic is locked

now() used in edit record field doesn't work

12/2/2005 08:30:22
PHPRunner General questions
S
sloftus author

I know that you can record the date a new record is entered by using now() in the Add New screen. If I store that in a datetime field in mysql and use the time format to display in the view as field (step 8) I can display both date and time in one field which is what I want.
However I'm also trying to do exactly the same to store the date/time when a record is edited. It doesn't work. What am I doing wrong?
Thanks,

Sergey Kornilov admin 12/2/2005

Hi,
the default values entered in PHPRunner are used when adding records only.

Because when editing a record the initial values are taken from database.
You can modify ..._edit.php file to update your datetime field each time when you edit a record.

Insert the following line :

$evalues["`Datefield`"]="now()";

just before this snippet:

foreach($evalues as $ekey=>$value)

$strSQL.=$ekey."=".$value.", ";


where Datefield is your actual field name.

S
sloftus author 12/2/2005

Thanks Sergey,
However to avoid having to manually edit ..._edit.php each time I rebuild the site is it possible to input an IF statement in the default value field for example IF the date already stored is null or not equal to now() then replace with now()? (Sorry I'm not conversant with code!)

Hi,

the default values entered in PHPRunner are used when adding records only.

Because when editing a record the initial values are taken from database.
You can modify ..._edit.php file to update your datetime field each time when you edit a record.

Insert the following line :

just before this snippet:
where Datefield is your actual field name.

Sergey Kornilov admin 12/5/2005

Hi,
default values are not used on Edit page, so there is no alternative to editing the pages manually.