Hi, I'm trying to get info from an API filled out into the fields of my form.After submit, I do see the array getting the info (debug). But the form disappears the page is empty.
On Submit this php code and need it to populate it on page1:
// VIN ophalen
$vin = $_POST['chassis'] ?? '';
// API
$url = "https://www.xxx.com/api/tracking?chassis=" . urlencode($vin);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
// Debug
// echo "<pre>"; print_r($data); echo "</pre>"; return;
if(!empty($data)){
$this->data['POL'] = $data['POL'];
$this->data['POD'] = $data['POD'];
$this->data['vessel'] = $data['vessel'];
$this->data['voyage'] = $data['voyage'];
$this->data['ETS'] = $data['ETS'];
$this->data['ETA'] = $data['ETA'];
$this->data['status'] = $data['status'];
$this->data['brand'] = $data['brand'];
$this->data['model'] = $data['model'];
$this->data['local_agent'] = $data['local_agent'];
}
return;
Hi comfix
You have this code inside a PHP action at the TOP of the Load event of your form page ?
Can you post a screenshot of the page actions and the debug ?
No it is at the submit button action, because 1st need to put in the VIN number so you get results returned back.
Alle fields are created and have the correct naming/value.

if you want to redisplay the form after the Submit then you need to use the "Reload page" action:

is this what you need ?
This seems to solve the issue and the fields are populated that is great! thanks )
Another question: when closing the page and opening it again, the data stays filled in. How to start with empty fields? So no caching or session saving whatsoever. Also would like to register how many time it has been used.
Great! 😊
At the top of the Load event, you can add a PHP action and use this code:
$this->data = [];
$this->vars = [];
that should clear the data for a new try, but you need to use if statement to check there was no POST:
if(empty($_POST)){
$this->data = [];
$this->vars = [];
}
