How to populate a text field by a form array value

How to populate a form text field with a database value in ChronoForms.

Overview

The issue occurs when trying to display retrieved database values in a form field for editing, often due to how the data array is structured.
Turn off the Mode ID in the DB Read action or use custom code in the 'On Found' event to assign the database value directly to the form field.

Answered
sa santosh.karkhanis 12 Dec, 2015
I am trying to test an edit of my data file already saved.
The method I am using id
1: Accept the key 'data field value for the record to be updated' using dynamic dropdown.
2. Pass the value to next page & copy the field values to form the database to form array.
3. Display the form field value in a text box & allow to change
4 Save the changed values to the data file.

I could able to do the first two steps, but can not populate the retried field values to the form for correcting.
I tried to add =[mydata][fname] in the 'Field Value' for the field (mydata is the model & fname is the field).
Can some one help, how can I populate the initial value for the field?

Screens are attached for clarity of understanding.
sa santosh.karkhanis 12 Dec, 2015
Answer
I could find the answer by some research.
I added the code in 'custom code' box at 'DB Read' 'On Found'
<?php
$form->data[fname] = $form->data[mydata][fname];
?>

Regards
Gr GreyHead 12 Dec, 2015
Hi Santosh,

The simplest answer is to turn off the Mode ID in the DB Read - you don't need it here.

Your code is fine - that works.

You could also change then name of the input element to [mydata]fname

Bob
This topic is locked and no more replies can be posted.