Buy Now
Sign in

Checkbox group in CFv5

isatyam , July 09 2014
Answered
I
isatyam
Hi,

I am having a small issue with CFv5. The data is getting saved correctly but when I retrieve it for editing the checkbox group data is not populated. All other fields are coming correctly.
Please help.

Regards,
Satyam
I
isatyam
Hi,

One more thing I noticed. If I just save one option in the checkbox group, it is retrieved perfectly. But when saving more than one option, the DB shows the options getting saved but the edit form does not retrieve them.

Any idea where I am going wrong?

Regards,
Satyam
admin
You may need to convert the data back to an array:

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

This code should go into a custom code action after the DB Read action!

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
I
isatyam
Hi Max,

I tried this also. Echoing $form->data["checkboxes_name"] gives Array ( [0] => Value1 [1] => Value2 [2] => Value3 )

So the data is getting converted back to array. The key and value for the checkboxes is same. Do you think this may be causing some problem?

Regards,
Satyam
admin
What are the original options list in your checkboxes group element ?

If they match the array then the boxes should be republished!

Regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
I
isatyam
Hi Max,

Thanx a lot for your help. There was a wrongly placed handle array action which was creating the issue. Your code solved the problem perfectly.

Regards,
Satyam
R
RobP
The Checkbox Group seems to work slightly different in V5.

The field must end with two brackets
  • , in V4 they were added by the program.
    If the Field name is Test the name in the Checkbox Group is Test


  • It still didn't work when I added them to existing fields, after renaming them and saving the form it worked (when I changed the name back it still worked).

    With a Model (in this case Model: Form and Fieldname: Test ) the systax is: Form[Test


  • To save the field in a table:
    Put a Handle Arrays in the On Submit before de DB Save.
    In the Handle Arrays fill in the fields, in this case: Form.Test (No brackets)

    Rob
    admin
    Thanks Rob, although v5 has few different things, but this is for the good, the brackets are added by default in v5 if you add a new "checkboxes group" element using the designer!

    Regards,
    Max
    Max
    If your main question got answered then please mark the answer using the button!​
    ​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
    R
    RobP
    The brackets are added but I keep al my fields an variables etc with a description in a separate file and paste them on the form, so the brackets were gone.

    With a large program it is easy to lose track (or make typo's).

    For a beginner with Chronoforms (like me) the syntax is not always completely clear.

    Rob
    B
    bytekultur
    Sorry to attach this here, but what you describe doesn't work for me. I use chronoforms5 and even set up my checkbox group again, changed the name of the field and changed it back etc. The brackets are added in the designer but don't appear in the source code, so I only ever receive the last option checked. Has any one solved that issue and knows what I am doing wrong?
    GreyHead
    Hi bytekultur,

    Three possible explanations:

    + you have two forms with the same name and the 'wrong' one is displaying

    + you have caching enabled in the site so that the changes aren't showing up until the cache expires

    + you have the form set to Custom Code and changes in the Designer are being ignored (actually I'm not sure this is possible)

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bytekultur
    Hi Bob, thank you for the quick answer.
    + you have two forms with the same name and the 'wrong' one is displaying
    No.

    + you have caching enabled in the site so that the changes aren't showing up until the cache expires
    No. I thought about that and deleted all cache, but the changes do show up, I have changed the name of the respective field and have seen the new name in the source code, but always without the brackets, even though they are set in the designer.

    + you have the form set to Custom Code and changes in the Designer are being ignored (actually I'm not sure this is possible)
    No. It's set to Wizard Designer.
    GreyHead
    Hi bytekultur,

    By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    GreyHead
    Hi bytekultur,

    Thanks for the link - the
  • are showing correctly there
    <div class="gcore-single-column" id="fclmn">
    <div class="gcore-checkbox-item" id="fitem">
    <input name="mycbxfield
  • " id="mycbxfieldid" class="A" title="" style="" data-load-state="" data-tooltip="" type="checkbox" value="No">
    <label class="control-label gcore-label-checkbox" for="mycbxfieldid">No</label>
    </div>
    <div class="gcore-checkbox-item" id="fitem1">
    <input name="mycbxfield[]" id="mycbxfieldid1" class="A" title="" style="" data-load-state="" data-tooltip="" type="checkbox" value="Yes">
    <label class="control-label gcore-label-checkbox" for="mycbxfieldid1">Yes</label>
    </div>
    </div>
    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bytekultur
    Thank you bob, as I mentioned in the private message - it might be a migration issue. Unfortunately, importing cf4 forms into chronoforms5 is not working too smoothly yet. I will have to manually transfer the fields and actions into a new form. Or if you have a better / quicker idea, please let me know! ;-)
    GreyHead
    Hi bytekultur,

    I've lost track of what the problem is here?

    The importer tool is not particularly useful, effectively it only imports the form HTML. In general it's better to stick with CFv4 for existing forms, create new ones in CFv5 and migrate the older ones over by re-building as and when they need to be updated.

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    B
    bytekultur
    Hi Bob, the problem was a checkbox group field which didn't accept [] brackets in the name. The answer to the question why seems to be that the form HTML has been imported from CFv4 which causes strange behaviour compared to a form created directly in CFv5. So the "solution", or a workaround, is for me to set up the form again manualy in CFv5 from scratch, I undestood there is no better way. No further assistance needed, thank you.
    B
    bytekultur
    To everyone running into this: after a bit of testing and setting up the same form again in CFv5 with no success, I got the reason for this issue. It's not the import tool but the multilanguage feature that causes it. I was using the strict match option for my locales, so every [] bracket couple found is replaced by the system. To quickly solve it, I set strict match to "no" and use the brackets in the locale strings. Changing all my language strings in the locale from something like this:

    FORM_FIRSTNAME=Firstname


    to something like that:

    [FORM_FIRSTNAME]=Firstname


    Hope it helps!
    Terry
    GreyHead
    Hi Terry,

    Thank you - I hadn't seen that particular problem before ;-(

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much