Update of data using PHP form plugin not working

VOI

Member
Hi,

I am trying to set some data after a form is submitted/updated. That is a counter for the times the form has been saved and the time of the last modification.

To do this I am using the form plugin php with 'Process Script' set to 'onAfterProcess' and the following code:

Code:
$views = $formModel->_formData['log_views'];
$formModel->updateFormData('projects___log_views', $views);
$now = time();
$formModel->updateFormData('projects___log_last_modified', $now);

However, the value of the two fields "log_views" and "log_last_modified" within the table 'projects' stay the same.

Neither altering the synatax by including a '_raw' after the element name and/or a ', true' after that as seen in some posts and the tooltip of the PHP code field nor changing the value of "Process Script" from 'onAfterProcess' to 'onLoad' or 'onBeforeProcess' showed any effect.

What am I doing wrong here?

Chris
 
Try
Code:
$views = $formModel->_formData['projects___log_views']; 
$formModel->updateFormData('projects___log_views_raw', $views);
 $now = time(); 
$formModel->updateFormData('projects___log_last_modified_raw', $now);
onBeforeStore
 
Thanks troester for the quick reply.

Tried your code - still no effect.:(

BTW: I changed the first line to

Code:
$views = intval($formModel->_formData['projects___log_views']) + 1;

as the counter otherwise would not be incremented.;)
 
You can debug by adding
var_dump($views);exit;
at the end.
This will show you a blank page with $views content and/or maybe any errors (e.g. typos in element names...)
 
Already tried that based on troester's post - no effect.

I get the impression that something is wrong with the handling of PHP code entered in the code field of the form PHP plugin.

Maybe it's caused by my site and its configuration.

What's the best way to check if the PHP code entered there is passed on or to debug that code? I am looking for something like Firebug for the server side.

Chris
 
Did you try this?
You can debug by adding
var_dump($views);exit;
at the end.
This will show you a blank page with $views content and/or maybe any errors (e.g. typos in element names...)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top