Buy Now
Sign in

Function calls in php code action

tshirley , May 20 2018, 11:56
tshirley 279
May 20 2018, 11:56 #377816
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);
$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.
simelas 173
July 25 2018, 16:44 #379252
Hi Tim,
i have done exactly the same e.g. :just changed "form" for "this" without noticeable issue.
best regards,