Buy Now
Sign in

Populate CFv6 form With CCv6 data

C
ctrlmedia 168
May 25 2017, 14:14 #368621
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
admin 28
May 25 2017, 17:07 #368635
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
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
C
ctrlmedia 168
May 25 2017, 20:47 #368642
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
Attachments
read-data.png
read-data.png
(31.16 KiB)
767 Downloads/Views
form-view.png
form-view.png
(47.53 KiB)
748 Downloads/Views
debug-data.png
debug-data.png
(312.24 KiB)
749 Downloads/Views
admin 28
May 26 2017, 05:44 #368645
 1
 Answer
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
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
C
ctrlmedia 168
May 26 2017, 07:39 #368655
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
C
ctrlmedia 168
May 26 2017, 08:25 #368658
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
admin 28
May 26 2017, 13:55 #368666
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
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
C
ctrlmedia 168
May 26 2017, 14:14 #368668
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
C
ctrlmedia 168
May 26 2017, 21:57 #368685
 1
Hi Max,
I got the explode to work like this:

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

Kind Regards
Mark
admin 28
May 27 2017, 09:02 #368696
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
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!