Forums

Changing a field value after submit

BNRBranding 19 Mar, 2015
Also have ChronoConnectivity 5.0.1.

I have created a connection that allows me to enter and edit records. All of that works great, I can go in and edit and save no problem, all of those fields work like I would expect.

The problem is that I also want to track the last date modified. It was working fine when I had it in CF4, but now the modified date is not being updated for some reason. I added a custom code action in the submit event before calling the connectivity action. This is the code I am using -

<?php
$form->data['Location.cf_modified'] = date("Y-m-d H:i:s");
?>


What am i missing?
fasenderos 20 Mar, 2015
I think Location.cf_modified is Model.fieldname.. try use only the table field name like this:

<?php
$form->data['cf_modified'] = date("Y-m-d H:i:s");
?>
GreyHead 20 Mar, 2015
Hi BNRBranding,

What is the name of the table column? If the table was created in CFV5 then it will probably be 'modified' rather than 'cf_modified'. Could that be the problem?

Bob
BNRBranding 20 Mar, 2015
The original table was created in CF4, that is the correct column name. I've tried both with and without the model on the field name. I'm pretty sure it needs to be there, I know it's required in the email template. Location.cf_modified works in the email that is sent after submit, but it uses the value from the DB rather than the value I am trying to assign.
BNRBranding 20 Mar, 2015
Answer
Figured it out. I had to turn off the CC5 action off so the debugger worked. Basically the actual form data was contained in a dimension of the data array. So I was close, I just need to change it to multidimension array bracket syntax.

<?php
$form->data["Location"]["cf_modified"] = date("Y-m-d H:i:s");
?>
This worked perfectly.
GreyHead 20 Mar, 2015
Hi BNRBranding;

Please try
<?php
$form->data['Location']['cf_modified'] = date("Y-m-d H:i:s");
?>

Bob
BNRBranding 20 Mar, 2015
You're 9 minutes late Bob! Thanks though, that is the correct solution.
This topic is locked and no more replies can be posted.