Buy Now
Sign in

HowTo update the model from a loop in CF7

ddipardo , August 08 2020, 10:41
D
ddipardo 3
August 08 2020, 10:41 #393588
I've created a form which contains a table list with a datasource read_data_test, with model name Test
I've added a loop with custom PHP code to calculate a result.
How do you update the value in the table list?
The PHP code below is executed in the PHP custom code of the Loop function.
$this->set("read_data_test.fieldname",$calculatedVar);
$this->set("Test.fieldname",$calculatedVar);
$this->set("Test[fieldname]",$calculatedVar);
None of those commands are updating either the read_data_test datasource or the Model.
Could someone point me in the right direction?
Thanks,
/D
admin 33
August 16 2020, 21:58 #393653
You will need to update a variable before the loop then use the updated variable as the loop data source!
D
ddipardo 3
September 23 2020, 13:16 #394038
Could you please be so kind to give some example since it doesn't make any sense to me. It might be as well the lack of documentation as I have no reference on how to do this
D
ddipardo 3
September 23 2020, 13:22 #394039
By trial and error I figured out to write the read_data variable back after modification which did the trick