I really like working with Chronoforms and have lots of successful forms, but now have a problem I can't solve, despite finding apparent solutions in the forum.
I want to add a timestamp to the $form->data array when the form is submitted. The form works well and sends email, writes to a database table and populates a Google spreadsheet properly, so I'm confident that the form works correctly. I'm using GSheet as the data model for the form so I've added a simple custom code entry to the On submit section of the setup as follows:
Unfortunately, it doesn't seem to work. What am I missing? Thanks in advance for any help you can offer.
I want to add a timestamp to the $form->data array when the form is submitted. The form works well and sends email, writes to a database table and populates a Google spreadsheet properly, so I'm confident that the form works correctly. I'm using GSheet as the data model for the form so I've added a simple custom code entry to the On submit section of the setup as follows:
<?php
$form -> data [ 'GSheet' ] [ 'postmark' ] = date ( 'Y-m-d H:i:s' ) ;
?>
Unfortunately, it doesn't seem to work. What am I missing? Thanks in advance for any help you can offer.
Hello dgorsborne,
Did you add the "custom code" action BEFORE the action Google save action ?
Best regards,
Max
Did you add the "custom code" action BEFORE the action Google save action ?
Best regards,
Max
Yes, it's the first item in the On submit block. All the other actions follow and, as I said, work as they should.
Hi dgorsborne,
Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.
Bob
Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.
Bob
Hi Bob,
Thanks for your reply. It prompted me to look again at the output from the debugger, and I suddenly had a thought - mentioned, I think, in other threads on the forums, that Custom Code is fussier about extra whitespace than PHP in general. So, I removed all the additional spaces from my code (see below) and it worked. I didn't change anything else in the form design or setup, so I think that must have been the problem. The form now writes properly to the Google spreadsheet and to the Joomla! DB table, and creates and sends the appropriate emails.
The custom code now reads:
Thanks again for your help. I'd be happy for this to be marked as 'solved'.
David (dgorsborne)
Thanks for your reply. It prompted me to look again at the output from the debugger, and I suddenly had a thought - mentioned, I think, in other threads on the forums, that Custom Code is fussier about extra whitespace than PHP in general. So, I removed all the additional spaces from my code (see below) and it worked. I didn't change anything else in the form design or setup, so I think that must have been the problem. The form now writes properly to the Google spreadsheet and to the Joomla! DB table, and creates and sends the appropriate emails.
The custom code now reads:
<?php
$form->data['GSheet']['postmark']=date("Y-m-d H:i:s");
?>
Thanks again for your help. I'd be happy for this to be marked as 'solved'.
David (dgorsborne)
Hi David,
PHP in general is fairly fussy about spaces - at least some spaces - I had assumed (wrongly) that those must have been added when you copied and pasted the code here :-(
Bob
PHP in general is fairly fussy about spaces - at least some spaces - I had assumed (wrongly) that those must have been added when you copied and pasted the code here :-(
Bob
Yes, I fell over the 'some spaces' bit. Thanks again.
This topic is locked and no more replies can be posted.
