Forums

How to load database information to checkbox group

kmikko 20 Mar, 2015
How to load data back from database to checkbox group?
Using same form with ChronoConnection with field name
TestData2[valikko[]]
I guess this is somehow wrong way to do this?

Form also has field TestData2[Name]. That works just fine.

-kmikko
Max_admin 20 Mar, 2015
Answer
1 Likes
Hi kmikko,

First of all, please update CCv5 to the latest version.

The field name should be: TestData2[valikko][]

The problem is that if you have a "Handle arrays" action before the save action then the values are concatenated using commas, and now you will need to separate them again, using PHP code inside a "custom code" action before the "HTML" action:

<?php
$form->data["TestData2"]["valikko"] = explode(",", $form->data["TestData2"]["valikko"]);


Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
kmikko 21 Mar, 2015
Thank you! Works like dream.

-kmikko
jmahun 05 Jun, 2015
What if I'm using a different form to retrieve the data? I used one form with a Handles Array and DB Write to create the table. My second form uses DB Read to extract a record. How do I extract the individual elements from the concatenated field?
I tried adapting the custom code shown for my situation but it didn't work. Not knowing much about php, however, means I could have screwed it up. In $form->data["TestData2"]["valikko"] are TestData2 the form name and valikko the field name?
GreyHead 06 Jun, 2015
Hi jmahun,

Please see my reply to your other post with the same question here

Bob
jmahun 06 Jun, 2015
Got it. Thanks.
This topic is locked and no more replies can be posted.