Buy Now
Sign in

Function calls in php code action

tshirley , May 20 at 11:56
T
tshirley
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