Forums

load data from record into a checkbox group

thewelt 09 Apr, 2016
Hi,

Via a form I saved data from a checkbox group into a record as option1,option2,option4. I got it working using a "handle array".
Now I want to retrieve the "option1,option2,option4" again into a form as a checkbox group where option1, option2 and option4 are checked and option3 and option5 are unchecked.

How can I do this?

Tnx,
Bart Weltens
thewelt 09 Apr, 2016
tnx for the post, but this does not check the options. 😟
GreyHead 09 Apr, 2016
Hi Bart,

Please see this FAQ it it the same code for a CheckBox group.

Bob
thewelt 09 Apr, 2016
Hi Bob,

I did use this custom code but my checkboxes aren't checked.
I added debug info on page 1 of my form and debug info on page 2 of my form.

page 1 debug info:
Data Array
Array
(
    [option] => com_chronoforms5
    [chronoform] => meldingsformulier_tijdelijke
    [user_id] => 814
    [id] => 11
    [naam] => Bart Weltens
    [email] => bart.weltens@............
    [telefoon] => 04765................
    [diploma] => onderwijzer, preventieadviseur niveau 3
    [status] => niet-TADD
    [ambt_aanstelling] => Array
        (
            [0] => onderwijzer
            [1] => ICT
        )

    [werkstatus] => geenwerk
    [opdrachtbreuk] => 0
    [KBHA] => 
    [wens] => wilgeenwerk
    [beschikbaar] => 
    [uitbreiding] => 
    [halve_dagen] => WOE-VM,DO-NM
    [opm_uitbreiding] => 
    [vragen] => 
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [22] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `Data`.`id` AS `Data.id`, `Data`.`user_id` AS `Data.user_id`, `Data`.`naam` AS `Data.naam`, `Data`.`email` AS `Data.email`, `Data`.`telefoon` AS `Data.telefoon`, `Data`.`diploma` AS `Data.diploma`, `Data`.`status` AS `Data.status`, `Data`.`ambt_aanstelling` AS `Data.ambt_aanstelling`, `Data`.`werkstatus` AS `Data.werkstatus`, `Data`.`opdrachtbreuk` AS `Data.opdrachtbreuk`, `Data`.`KBHA` AS `Data.KBHA`, `Data`.`wens` AS `Data.wens`, `Data`.`beschikbaar` AS `Data.beschikbaar`, `Data`.`uitbreiding` AS `Data.uitbreiding`, `Data`.`halve_dagen` AS `Data.halve_dagen`, `Data`.`opm_uitbreiding` AS `Data.opm_uitbreiding`, `Data`.`vragen` AS `Data.vragen` FROM `eamfd_CF_meldingsformulier_tijdelijke` AS `Data` WHERE `Data`.`user_id` = '814'
                        )

                )

        )

)
page 2 debug info:

Data Array
Array
(
    [option] => com_chronoforms5
    [chronoform] => meldingsformulier_tijdelijke
    [event] => page2
    [naam] => Bart Weltens
    [email] => bart.weltens@kbha.be
    [telefoon] => 0476543159
    [diploma] => onderwijzer, preventieadviseur niveau 3
    [id] => 11
    [button8] => Naar pagina 2
    [ambt_aanstelling] => Array
        (
            [0] => 
        )

)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [23] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `id`.`id` AS `id.id`, `id`.`user_id` AS `id.user_id`, `id`.`naam` AS `id.naam`, `id`.`email` AS `id.email`, `id`.`telefoon` AS `id.telefoon`, `id`.`diploma` AS `id.diploma`, `id`.`status` AS `id.status`, `id`.`ambt_aanstelling` AS `id.ambt_aanstelling`, `id`.`werkstatus` AS `id.werkstatus`, `id`.`opdrachtbreuk` AS `id.opdrachtbreuk`, `id`.`KBHA` AS `id.KBHA`, `id`.`wens` AS `id.wens`, `id`.`beschikbaar` AS `id.beschikbaar`, `id`.`uitbreiding` AS `id.uitbreiding`, `id`.`halve_dagen` AS `id.halve_dagen`, `id`.`opm_uitbreiding` AS `id.opm_uitbreiding`, `id`.`vragen` AS `id.vragen` FROM `eamfd_CF_meldingsformulier_tijdelijke` AS `id` WHERE `id`.`user_id` IS NULL
                        )

                )

        )

)
GreyHead 09 Apr, 2016
Hi Bart,

Are the CheckBoxes 'diploma' ? if so it looks as if the code to explode the string is either not working or is in the wrong place. It needs to be after the DB Read action and before the HTML (Render form) action.

Bob
thewelt 09 Apr, 2016
Hi Bob,

The checkboxes are 'ambt_aanstelling'.
Not 'diploma'

Bart
GreyHead 09 Apr, 2016
Hi Bart,

What are page 1 and page 2? I can't work out what you are showing me here?

Bob
thewelt 09 Apr, 2016
Hi Bob,

I made some screenshots:
GreyHead 11 Apr, 2016
Hi Bart,

The problem might be the comma+space separator, are you exploding the list using ', ' ?

Bob
thewelt 11 Apr, 2016
Hi Bob,

Is used this custom code:

<?php
$form->data['ambt_aanstelling'] = explode(',', $form->data['ambt_aanstelling']);
?>

So only ',' and no space.
In the record there also is'nt a space between the words (see screenshot01.jpg).

Bart
thewelt 15 Apr, 2016
Hi,

I think I solved the problem.
The checkbox group was on the second page of my form. I copied it to my first page and the checkboxes are checked.
I don't know why this is bt ... problem solved.

tnx,
Bart
GreyHead 17 Apr, 2016
Hi Bart,

The saved data that you loaded on the first page isn't automatically carried through to the second page; you can either:

a. use a second DB Read to get the next batch of data

b. add the data to the first page form in hidden inputs

c. add the data to the User session with Data to Session and Session to Data (or Multipage) actions.

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