Forums

Edit form not loading checkboxes

MaestroC 12 Feb, 2015
I read a few places on the forums where people were having issues getting their checkboxes to populate properly when using an edit form. As instructed on one of them we added this to a custom code action just above the render HTML:

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


Unfortunately it does not seem to be working. All the other fields populate properly with the saved information but the check boxes do not. Do you have any other suggestions for getting this running? The debug info shows that the data is correctly being retrieved from the db:

    [checkbox_group15] => Window Sticker or Dealer Invoice,Build Sheet,Broadcast Card,Original Owner Verified,GM of Canada Paperwork,Other,No Documentation


Any ideas?
MaestroC 12 Feb, 2015
Forgot to paste in the debug code from the form. This is what I get when oprning the edit form. Everything loads correctly except for the checkboxes:

Data Array
Array
(
    [cont] => lists
    [ccname] => mycar_listing
    [act] => edit
    [gcb] => 17
    [mycarList] => Array
        (
            [id] => 17
            [uniq_id] => c53d6a08ac66d1f049b5b6fa87f29dc533c3435c
            [user_id] => 144
            [created] => 2015-02-11 04:22:24
            [modified] => 2015-02-12 03:27:48
            [userID] => 
            [firstName] => Chad
            [lastName] => C
            [city] => Altoona
            [state] => IA
            [country] => USA
            [email] => chadc@xxxxxxxxxxxxx
            [phone] => 5155551212
            [shareInfo] => 1
            [year] => 1970
            [bodyStyle] => Rallye 350 - Cutlass S Holiday Coupe 3687
            [vin] => 123123123xxxxx
            [checkbox_group15] => Window Sticker or Dealer Invoice,Build Sheet,Broadcast Card,Original Owner Verified,GM of Canada Paperwork,Other,No Documentation
            [odometer] => 12345
            [currentlyOwned] => 1
            [yearsOwned] => 1
            [dealership] => My Place
            [buildDate] => 1/28/70
            [transmission] => M40 Turbo Hydra-matic 400 (column)
            [axelratio] => 3.23 (G91)
            [wheels] => Super Stock II (Body Color)
            [color] => 53-Nugget Gold
            [stripeColor] => Gold
            [interiorColor] => Blue
            [currentExteriorColor] => 26-Viking Blue*
            [currentStripe] => Rallye 350 Decals
            [currentInterior] => Blue
            [checkbox_group29] => AA3 Tinted Roof Glass,A01 Tinted Body Glass,A02 Tinted Windshield,A31 Electric 4-Window Lifts,A33 Electric Rear Window (Tailgate),A39 Deluxe Seat Belts Front and Rear,A41 Electric 4-Way Seat (Bench),A42 Electric 6-Way Seat (Bench),A46 Electric 4-Way Seat 
            [modelYear] => 70
            [division] => 3-Oldsmobile
            [bodyStyle2] => 4467
            [assemblyPlant] => LAN-Lansing
            [bodyUnit] => 123456
            [TR] => 990
            [PNT] => 20-Azure Blue
            [PNTupper] => 19-Ebony Black
            [timeBuiltMonth] => 05-May
            [timeBuiltWeek] => D-Week 4
            [comments] => Test Comment
            [photo] => 20150211042224_contact-300.jpg
            [docPhoto2] => 20150211042224_Links-300.jpg
            [docPhoto] => 
            [button43] => Submit
        )

    [checkbox_group15] => Array
        (
            [0] => Window Sticker or Dealer Invoice
            [1] => Build Sheet
            [2] => Broadcast Card
            [3] => Original Owner Verified
            [4] => GM of Canada Paperwork
            [5] => Other
            [6] => No Documentation
        )

)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [14] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `mycarList`.`id` AS `mycarList.id`, `mycarList`.`uniq_id` AS `mycarList.uniq_id`, `mycarList`.`user_id` AS `mycarList.user_id`, `mycarList`.`created` AS `mycarList.created`, `mycarList`.`modified` AS `mycarList.modified`, `mycarList`.`userID` AS `mycarList.userID`, `mycarList`.`firstName` AS `mycarList.firstName`, `mycarList`.`lastName` AS `mycarList.lastName`, `mycarList`.`city` AS `mycarList.city`, `mycarList`.`state` AS `mycarList.state`, `mycarList`.`country` AS `mycarList.country`, `mycarList`.`email` AS `mycarList.email`, `mycarList`.`phone` AS `mycarList.phone`, `mycarList`.`shareInfo` AS `mycarList.shareInfo`, `mycarList`.`year` AS `mycarList.year`, `mycarList`.`bodyStyle` AS `mycarList.bodyStyle`, `mycarList`.`vin` AS `mycarList.vin`, `mycarList`.`checkbox_group15` AS `mycarList.checkbox_group15`, `mycarList`.`odometer` AS `mycarList.odometer`, `mycarList`.`currentlyOwned` AS `mycarList.currentlyOwned`, `mycarList`.`yearsOwned` AS `mycarList.yearsOwned`, `mycarList`.`dealership` AS `mycarList.dealership`, `mycarList`.`buildDate` AS `mycarList.buildDate`, `mycarList`.`transmission` AS `mycarList.transmission`, `mycarList`.`axelratio` AS `mycarList.axelratio`, `mycarList`.`wheels` AS `mycarList.wheels`, `mycarList`.`color` AS `mycarList.color`, `mycarList`.`stripeColor` AS `mycarList.stripeColor`, `mycarList`.`interiorColor` AS `mycarList.interiorColor`, `mycarList`.`currentExteriorColor` AS `mycarList.currentExteriorColor`, `mycarList`.`currentStripe` AS `mycarList.currentStripe`, `mycarList`.`currentInterior` AS `mycarList.currentInterior`, `mycarList`.`checkbox_group29` AS `mycarList.checkbox_group29`, `mycarList`.`modelYear` AS `mycarList.modelYear`, `mycarList`.`division` AS `mycarList.division`, `mycarList`.`bodyStyle2` AS `mycarList.bodyStyle2`, `mycarList`.`assemblyPlant` AS `mycarList.assemblyPlant`, `mycarList`.`bodyUnit` AS `mycarList.bodyUnit`, `mycarList`.`TR` AS `mycarList.TR`, `mycarList`.`PNT` AS `mycarList.PNT`, `mycarList`.`PNTupper` AS `mycarList.PNTupper`, `mycarList`.`timeBuiltMonth` AS `mycarList.timeBuiltMonth`, `mycarList`.`timeBuiltWeek` AS `mycarList.timeBuiltWeek`, `mycarList`.`comments` AS `mycarList.comments`, `mycarList`.`photo` AS `mycarList.photo`, `mycarList`.`docPhoto2` AS `mycarList.docPhoto2`, `mycarList`.`docPhoto` AS `mycarList.docPhoto`, `mycarList`.`button43` AS `mycarList.button43` FROM `uzt8u_chronoengine_chronoforms_datatable_CarRegistrationForm2` AS `mycarList` WHERE `mycarList`.`user_id` = '144'
                        )

                )

        )

)
GreyHead 13 Feb, 2015
Hi MaestroC,

Please try:
<?php
$form->data['mycarList']['checkbox_group15'] = explode(',', $form->data['mycarList']['checkbox_group15']); 
 ?>
MaestroC 14 Feb, 2015
No luck. It still is not pulling in the data from the checkboxes. The new debug data after I pasted in the code you provided is included below.

Array
(
    [cont] => lists
    [ccname] => mycar_listing
    [act] => edit
    [gcb] => 26
    [mycarList] => Array
        (
            [id] => 26
            [uniq_id] => 2961dbe94534ee515324d37b70c705e96bd2c15a
            [user_id] => 168
            [created] => 2015-02-13 04:45:58
            [modified] => 2015-02-13 05:37:54
            [userID] => 
            [firstName] => First
            [lastName] => Last
            [city] => 
            [state] => ON
            [country] => Canada
            [email] => 1xxxx@xxxx.com
            [phone] => 
            [shareInfo] => Yes
            [year] => 1970
            [bodyStyle] => F-85 W-31 Sports Coupe 3277
            [vin] => 332770M2XXXXX
            [checkbox_group15] => Array
                (
                    [0] => Broadcast Card
                    [1] => GM of Canada Paperwork
                )

            [odometer] => 62880
            [currentlyOwned] => Yes
            [yearsOwned] => 3
            [dealership] => Richardson Auto Sales Ltd. Ontario
            [buildDate] => 01/29/1970
            [transmission] => M38 Turbo Hydra-matic 350 (column)
            [axelratio] => 3.42 (G92)
            [wheels] => Steel Wheels with Poverty Caps
            [color] => 28-Twilight Blue
            [stripeColor] => Blue
            [interiorColor] => Blue
            [currentExteriorColor] => 28-Twilight Blue
            [currentStripe] => Blue
            [currentInterior] => Blue
            [checkbox_group29] => A01 Tinted Body Glass,B30 Floor Carpet Front and Rear,B90 Chrome Door Window Frames,D35 Rear View Mirror - Outside - Sport,FE2 442 Suspension Package,G80 Anti-Spin Axle,N10 Dual Exhaust,N34 Custom Sport Steering Wheel,P06 Wheel Trim Rings,PK5 Fiberglass Blackwall Tires - Wide Oval,U63 Deluxe Radio,U80 Rear Seat Speaker,VO2 H.D. Radiator 3.42 Axle,W31 W-Machine Package,Y60 Accessory Group
            [modelYear] => 70
            [division] => 3-Oldsmobile
            [bodyStyle2] => 3277
            [assemblyPlant] => LAN-Lansing
            [bodyUnit] => XXXXXX
            [TR] => Z903
            [PNT] => 28-Twilight Blue
            [PNTupper] => 28-Twilight Blue
            [timeBuiltMonth] => 01-January
            [timeBuiltWeek] => D-Week 4
            [comments] => 
            [photo] => samw31.jpg
            [docPhoto2] => 20150213044558_image.jpg
            [docPhoto] => 20150213044558_image.jpg
            [button43] => Submit
        )

)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [14] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                        )

                )

        )

)


Also, once we get this to work how do I make it also work for a second set of checkboxes on the same form? Do I just put the same code with the different field name in the same custom code box or do I need to make a second custom code module in the form setup?
GreyHead 14 Feb, 2015
Hi

As you can see the data is in the right place now
    [mycarList] => Array
        (
            [id] => 26
            ...
            [checkbox_group15] => Array
                (
                    [0] => Broadcast Card
                    [1] => GM of Canada Paperwork
                )
So maybe the checkbox group isn't called checkbox_group15 in your form?

And yes you can add a similar line in the same Custom Code action for any other checkbox groups.

Bob
MaestroC 14 Feb, 2015
Okay, I think I understand. On the original entry form it is checkbox_group15[] but in the edit form in the field name box it is called mycarList[checkbox_group15[]]

Do I need to change the php code somehow to include the mycarList? If so could you tell me how? Sorry... Again...
GreyHead 15 Feb, 2015
Hi MaestroC,

This doesn't look right mycarList[checkbox_group15[]] - I think it should be mycarList[checkbox_group15][]

Bob
GreyHead 16 Feb, 2015
Hi MaestroC,

Please try changing that to mycarList[checkbox_group15][]

Bob
MaestroC 17 Feb, 2015
That did it! Thank you again for all the assistance with this!
This topic is locked and no more replies can be posted.