Forums

Basic understanding of using PHP to create formdata

jj135 18 Sep, 2017
Hi! I'm still kind of struggling with the new concept of CF6 and tags like {data:...} and {var:...) etc. So for my understanding:

When I want to use PHP to create a new value (like the page title, or a calculation, or whatever), how do I get this in the data / email of the form?

Do I need to add a PHP script in the setup 'load' section in the form to create the new value like this:

<?php $myVariable = "test";?>

And the add this somehow as a value to a hidden form elemenent? How?
Or can I use this PHP variable in the email body without adding it to a hidden field? How?

Or are both option possible?

Hope you can help me clarify this ;-) Thanks!

Kind regards,
Jip
GreyHead 18 Sep, 2017
Hi Jip,

Please see the examples at the foot of Page 34 in the manual
$this->set('var_name', 'value);
You can use this in a Custom Code action in the form On Load or On Submit event and then use the data like any other data item in later actions.

Bob
jj135 18 Sep, 2017
So when I add this:

$this->set('mytest', 'hello');

I can use it like this: {data:mytest} ?
GreyHead 19 Sep, 2017
Hi jj135,

I'm not sure, I've done some experiments with mixed results - will try again later.

Bob
This topic is locked and no more replies can be posted.