Function calls in php code action

ts tshirley 20 May, 2018
Hi,
​
I have just started converting some CF5 forms to CF6.
​
I had in CF5 some custom code to populate a form after API call to a database:
​
$form->data['field1'] = $sr['field_1'];
​
​
So I started to change to the CF6 function calls, but then in testing I found that both:
$this->data('field1', $sr['field_1'],true);
and
$this->data['field1'] = $sr['field_1'];
​
both seem to populate the form field. So maybe I just have to change "form" to "this". in each line. Being quite lazy, I am wondering if there is any problem with using the second format throughout my converted forms, or if it is necessary to use the CF6 function calls for some reason.
​
Cheers
​
Tim
si simelas 25 Jul, 2018
Hi Tim,
​
i have done exactly the same e.g. :just changed "form" for "this" without noticeable issue.
​
best regards,
​
simelas
This topic is locked and no more replies can be posted.