How to load record data from a database table into your form

In order to load data from an existing record into your form, you will need to use the DB Read action, just place it in your On Load event (or any other form event based on your needs). Note that the action should be placed *above* the HTML (Render form) action, in order for the data to be loaded before the form is displayed.

Inside the 'DB Read' setting you will need to select the database table to read the data from, and you will need to map some request parameter (or any PHP variable) to a db table field, this 2nd step is done using the Conditions box, you can use the code below:

<?php
return array("db_field_name" => $form->data("request_param_name"));
?>

Your form fields names should match the database table fields names, and if you choose to load the data under the Model ID then your form fields names should have the Model id inside, e.g: Model[field]

You can see the original CFv4 FAQ here

Category: ChronoForms v5

Comments:

You need to login to be able to post a comment.