Forums

Populate CFv6 form With CCv6 data

ctrlmedia 25 May, 2017
Hi,

I have a Connection using CCv6.
I have loaded a CFv6 form using {chronoform/section:form-alias/one}
I have loaded a read data within CCv6. (named read-most-recent-tracker)

All of this works fine according to the debugger.
The data is in [read-most-recent-tracker][tracker]

How do I get that data to populate the field values in the form?

Do I need to load the data using CFv6?


Regards
Max_admin 25 May, 2017
Hi Mark,

Set the data provider in the form view in your connection to the data source.

{var:read-most-recent-tracker.tracker}

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
ctrlmedia 25 May, 2017
Hi Max,

I have done that, I have attached a screenshot of the "read data" function. (I have changed the name since last post)
I have attached an image of the "form view".
The last image is of the debug on the page showing how the data is.

So if I had an input in the form to have the value of "aid" what would the name of that input have to be to display the value? Just "aid"?

[read_recent_tracker][tracker][aid]

Thanks for the help.
Regards
Mark
Max_admin 26 May, 2017
Answer
1 Likes
Hi Mark,

The data which the form receives is the data under {var:read-most-recent-tracker.tracker}, and so your form field name should be just "aid", but your debug shows that your "read data" is returning an array or results, you should set the read data to return the first matching record only.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
ctrlmedia 26 May, 2017
Ah OK Max,

This is now working.
In case others want to know how this was resolved.

In the "Read Data" I had to set "Data Settings -> Select Type" to "First Matching Record". Even though I had set the limit to 1 it was still coming in as an array. Changing this stopped it being an array and just brought the single record.

You can see in the debug-data image above that there is "[var] [0] [tracker]" I just needed "[var] [tracker]" for it to work.

Thanks for your help Max.
Regards
Mark
ctrlmedia 26 May, 2017
HI Max,
In this scenario how would I populate a Checkbox Group?

I don't seem to be able to target the data to explode it like other examples I have seen. I have used the below in CCv6 php after the "Data Read".

Data I want to change -> [read_recent_tracker][tracker][cancerscreening] => breast,bowel,cervical

$form->data["read_recent_tracker"]["tracker"]["cancerscreening"] = explode(",", $form->data["read_recent_tracker"]["tracker"]["cancerscreening"]);


Regards
Max_admin 26 May, 2017
Hi Mark,

if you are saving the checkbox data as a json encoded string then you can add this in the "special fields" box of the read data:
checkbox_table_field/json


If not then use the code you have and replace $form by $this

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
ctrlmedia 26 May, 2017
Hi Max,

Neither of these seem to work?

I don't really understand what a "json encoded string means" I'm afraid. When saving they are just a standard CFv5 checkbox group which stores the data in to a VARCHAR cell in the DB.
Looking at the data it is just "breast,bowel,cervical" in the column called "cancerscreening".
My checkbox group that I want to load the values back in to is "cancerscreening[]".

I have changed the php to use $this as suggested but with no luck.
When I did the json suggested fix it just removed the value in "cancerscreening" within debug.

Kind Regards
Mark
ctrlmedia 26 May, 2017
1 Likes
Hi Max,
I got the explode to work like this:

$this->data["cancerscreening"] = explode(",", $this->get("read_recent_tracker.tracker.cancerscreening"));

Kind Regards
Mark
Max_admin 27 May, 2017
Hi Mark,

Good, but for best results, its better to save the array data in json format, this is better than concatenating them with commas.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.