Forums

Checkboxes in CF5 from a list in CC5

Merou63 04 May, 2017
Hello,
I use a checkbox group on a Chronoform v5 form.
In the options of the checkbox field in the designer, I put a series of lines with value = title.
I put "handle array" in the "submit" and everything is written well in the table.
But when rereading an existing record the checkboxes are empty.
I come on the form from a Chronoconnectivity list.
Is there something to indicate in the "on load" or something else done to fill the checkboxes?
Thanks in advance for your help,
Marc
GreyHead 04 May, 2017
Hi Marc,

When you re-load the data you have to convert the list back into an array and the Handle Arrays action doesn't do that for you :-( You need to use a Custom Code action in the form On Load event before the HTML (render form) action with code like this
<?php
$form->data['checkbox_group_name'] = explode(',', $form->data['checkbox_group_name']);
?>

Bob
Merou63 04 May, 2017
Hello Bob,
Wow! Thank you for this fast and relevant response !
I knew that it was necessary to explode the field to fill the checkboxes but I was looking for an equivalent to 'handle array but the code is perfect!
Here is the code I indicated:
 <? php
      $ Form-> data ['interest'] = explode (',', $ form-> data ['interest']);
   ?>

It does not work 😟, I probably made a mistake, on the name maybe?
I attach a print screen of the configuration of my checkboxes.
Again thanks for the help and for these great components, I am looking forward to testing version 6.
Marc
GreyHead 04 May, 2017
Hi marc,

In your code it needs to be $form in both places with lower-case f and no spaces.

The element name should not have the brackets nested - use EDT_Users[interest][] instead. And remove the [] from the id as they are not allowed there in valid HTML.

As you have a sub array the code needs to reflect that
<?php
$form->data['EDT_Users']['interest'] = explode( ',', $form->data['EDT_Users']['interest'] );
?>

Bob
Merou63 04 May, 2017
Hello Bob,

Thank you for the answer.

I had no capital or space in my code, I think it's a problem with Google translation, sorry.

My code is now:
<?php
$form->data['EDT_Users']['[interest'] = explode( ',', $form->data['EDT_Users']['[interest'] );
?>
But it still does not work ! 😟

My page is here: http://www.edt-sbp.be/index.php/phd-students/doctoral-list
In fact "EDT_Users" is the name of the model used in the Chronoconnectivity list.

In the code you sent me, I do not understand the usefulness of the [ just before interest.
I tried removing this [ but it does not work either ...

I am sorry to ask such basic questions.

Thank you again for your help.
Marc
GreyHead 04 May, 2017
Hi Marc,

Sorry, I left an extra [ in before interest - I have corrected my earlier post.

Bob
Merou63 04 May, 2017
Hi Bob,
It still does not work, I had already corrected it.
Is the problem not due to the fact that the form is called by a Chronoconnectivity list?
Thank you for your patience and advice,
Marc.
GreyHead 05 May, 2017
Hi Marc,

You haven't changed the name of the CheckBox group in the form - I still see
<input name="EDT_Users[interest[]]" id="interest[]5" class="A" . . . value="PPP">
Please try with the name EDT_Users[interest][] and the id just interest.

Bob
Merou63 05 May, 2017
Yessssssssss !!!
It's work fine now 😀😀😀
And, in addition, I understood where my mistake was !
Thank you very much !
Marc
This topic is locked and no more replies can be posted.