referring to an Array element

How to reference database array elements in ChronoForms custom code.

Overview

The issue occurs when trying to access specific array elements from a database record retrieved by a CF DB Read action within a custom code action.
Use the $form->data array with the column name as the key. If a Model ID was set in the DB Read, use $form->data['model_id']['column_name']. Temporarily add a Debugger action to inspect the available data structure.

Answered
dt dtws2008 04 Dec, 2015
Hello,
In my form, after the db read action I use a custom code action.
In the custom code I want to refer to an Array element of the retrieved record. How can I do this?
Gr GreyHead 04 Dec, 2015
Hi dtws2008,

It will either be $form->data['column_name'] or $form->data['model_id']['column_name'] depending on whether you set a Model ID in the DB Read action.

Adding a Debugger action temporarily will show you the data available.

Bob
dt dtws2008 04 Dec, 2015
Hello Bob,
I need to update a $form->data['column_name'] by a calculation of some array elements that were retrieved by the DB read.
How to refer to the array elements? not the form fields.
dt dtws2008 04 Dec, 2015
Sorry, my mistake!
This helped me! Thanks a lot
Gr GreyHead 04 Dec, 2015
Answer
1 Likes
Hi dtws2008,

As you have seen the DB Read data is added to the $form->data array in addition to the data from the form inputs.

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