Forums

Array packing/unpacking with Connectivity and Forms

farmington 14 Feb, 2015
I have a Chronoform that collects preferences from the user via check boxes.
When I load straight into it using the current user, it explodes and implodes the information correctly between the database and the checkboxes (using a custom Action with an explode function I found elsewhere on this site, plus the Handle Arrays action on Submit).

However, elsewhere I display a list of users using ChronoConnectivity, and have an Edit button that links to a similar Chronoform. The checkboxes cause a problem here. I have to rename the fields using the Linkname[fieldname] convention, but the checkboxes are already in fieldname[] format. So should they be named as Linkname[fieldname[]] ? The exploding of the array on form load doesn't seem to populate the check boxes correctly.

On save, I have an even bigger problem. I get the following error:
Fatal error: Call to undefined method GCore\Libs\Arr::is_assoc() in /home/farming9/public_html/administrator/components/com_chronoforms5/chronoforms/actions/handle_arrays/handle_arrays.php on line 66

I could use any assistance you can offer.
Max_admin 14 Feb, 2015
1 Likes
Hi farmington,

You should always install the latest CF AFTER CC

The checkboxes name should be:
Linkname[fieldname][]


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
farmington 14 Feb, 2015
I just posted another question concerning the installation of these two packages interfering with each other. At the point I was testing this, I had to have CC installed most recently (otherwise the display of the table with the Edit link wouldn't have been working).

I changed the checkbox names as you suggested, and it doesn't seem to have changed the behavior, either on unpacking or saving (though the saving problem could be related to the conflict between the two packages).
Max_admin 15 Feb, 2015
Ok, a new update is scheduled for later today, please try again after installing that one and let me know!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
farmington 15 Feb, 2015
The two packages seem to be playing better together now. I installed the new CC extension followed by the CF. I can now both edit forms and view a CC table page without switching between the installations.

As far as the checkboxes - it still doesn't seem to be unpacking them when the form loads. The only checkbox that is checked on form load is the first (i.e. if the imploded data is '2,3,4' then only box 2 is checked upon form load). When I try to save the form, I don't get the full-screen fatal error any more. However, I get a red box in the display area that says "Connection not found".
Max_admin 16 Feb, 2015
When exactly do you get the "Connection not found" ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
farmington 16 Feb, 2015
I have a CC data table, with "Edit" links enabled for each line item.
Clicking on "Edit" takes you to a CF form, where checkbox data needs to be exploded into a group of checkboxes (currently, the state is only being reflected for the first selected item).
Then, on clicking "Submit" on the CF detail form, I get the "Connection Not Found" error.

If you'd like, I can send you a private message with the info for my site, with a username that will allow you to see this.
farmington 17 Feb, 2015
Oops - I realized the Connection Not Found error was mine. It hadn't made it that far before without error-ing out, so I hadn't noticed that I had named the Connection Action incorrectly.

However, it still doesn't seem to correctly handle the arrays on opening the form. It only populates the first selected item (i.e. if the database has '2,3,4' then only item 2 is checked upon form load). I am using exactly the same Custom Code for exploding the checkboxes as I use on a similar form that doesn't use CC.

It IS saving the information correctly. When I look directly at the data in MySQL, it is storing the values correctly.
Max_admin 17 Feb, 2015
Answer
1 Likes
The explode code should be something like this:

<?php
if(!empty($form->data["Model"]["checkboxes_field"])){
$form->data["Model"]["checkboxes_field"] = explode(",", $form->data["Model"]["checkboxes_field"]);
}


The code should be in a "custom code" ABOVE the HTML action.

Is this what you have ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
farmington 17 Feb, 2015
I had similar code in a Custom Code block above the HTML, but it didn't have the fully-qualified data link with the "model" in there. Now it works! Thanks so much for your help.
This topic is locked and no more replies can be posted.