Forums

checkboxes group - help

the_fitz 08 Jul, 2013
Hi all,

I have a form with a Checkbox group field "co_link"

I use the dynamic data and it is coming in from another table.

The data is displaying correctly.

However, when selecting more than 1 checkbox, it only save the first check on the list.

How do I make it both save multi checkboxes, and redisplay the checked checkboxs?

The "co_link" field is a varchar 255, if I inspect the field value, it shows only a single id number, I would think it would have to have multiple id numbers based on the selections made.

The id and text values from the second table are "id" and "nom".

Thanks in advance for your help.
MrFitz
GreyHead 08 Jul, 2013
Hi MrFitz,

Is this a case for Handle Arrays? Please see this FAQ which may help.

Bob
the_fitz 08 Jul, 2013
Hi Bob,

Well, That is very interesting, but I am dealing with "Dynamic" data not static data, so I do not have the chance to "Build" the arrays like the example, I tried putting the "Handle arrays" where suggested ,but it does not work.

The dynamic data is getting put into arrays, but I am lost as to where to include this code (from the example)
$co_venue = array();
foreach ( $form->data['venues'] as $v ) {
  $venue_names[] = $venues[$v];
}
$form->data['venue_names'] = implode(', ', $venue_names);
?>


It is to be saved in a separate linked table (profile_venues).
This table has an Auto-id = pv_id (primary Key)
This table has a user_id_link = (key)
This table has a venue_id_link = (key)

This links to a 3rd table (venue_list) that has
id = venue id
nom = venue human readable name

So my form must list all choices from venue_list and allow the user to select one or more venues, and then should store those results in the profile_venues table and display those selected on a profile form, that is linked to the profile_venues table by the user_id_link.

And all this will just let me use "handle arrays" and it will work????
I can't get it to happen....
GreyHead 09 Jul, 2013
Hi TheFitz,

I'm sorry but I find it hard to understand the sequence here.

By 'Dynamic Data' I assume that you mean that you are getting it from a DB Multi Record Loader?? If so it will be added to the $form->data array and you can use a Custom Code action to process it with PHP. The Handle Arrays action might so it correctly but I'm not certain of that.

Bob
the_fitz 09 Jul, 2013
Hi Bob,

Well, I've been working with it. No joy yet, but I think that may have put me on the trail. I'll let you know.

Thanks
MrFitz
the_fitz 09 Jul, 2013
Hi Bob

I still can't get this, so I tried another form and I am against a similar problem...

I can't display a table within a table, please help...!!!

I am using a form with a single custom HTML/PHP element to just display a table.

The table is meant to display a few pieces of the user's info...

Main Table displays perfectly a single record related to that user.
item 1
item 2
item 3

item 5


these pieces of data all come from a single db table named "joom_rex_profile" with a primary key as "id_auto"

BUT item 4 is much trickier.... it is a 1 to many relationship

It represents 0 or more venues the user is at.
I have 2 more tables with that information.
1. "joom_rex_locations" Table which has many fields but the 2 that I care about are
"id" primary key
"nom" a descriptive name
2. "joom_rex_profile_venues" Table only as a linking table and only has 3 fields.
"pv_id" primary key, auto
"pv_pid_link" which is the link to "joom_rex_profile", "id_auto" field.
"pv_venue_id" which is the link to the "joom_rex_locations", "id" field

Item 4 needs to list the names (nom) for each venue.

I use a known method to get the "id_auto"... Then I need this....

select L.nom from joom_rex_profile_venues V, joom_rex_locations L where V.pv_pid_link = $id_auto AND V.pv_venue_id = L.id


(I know in a mysql "join", the order the tables are stated in the sql statement determine how the results look.)

Then I need to be able to "foreach" through and then display the names 0 to many, as item 4

I just can't get it..

I thought I would need the Multi-db data loader to load all the possible venues,
and then use the multi-db loader to load the user's list of ONLY HIS venues

But I can only load one or the other, they never both load....
Why is this so hard? And this is almost the same for my "Other" situation, the "Checkbox groups"

Is there a way I can make the db "select" call directly instead of using the Multi-db loader?

I also tried the "Handle arrays" But That does not seem to have any effect.

I am examining the results of the debug tool.

Thanks
MrFitz
GreyHead 10 Jul, 2013
Hi TheFitz,

Sorry, I had misunderstood what you are trying to do here.

I think that there are two choices; and in both cases I'd hand-code the MySQL queries rather than trying to use the DB Multi-Record Loader.

a) You do one query for all the data joining the tables; then you have to process the results to filter out each unique user record and the matching venue list.

b) you do one query to get the user list and then loop through the list doing a query for each user to get the matching venue list.

I'd probably go for the second - but I'm not expert in efficient MySQL!

Bob
the_fitz 11 Jul, 2013
Hi Bob,

That helped a lot. I have this situation in 2 forms, ONE is a static "display only" form (no submit button) and it is now working 100%, Thank You. The other one is a problem.

I had to Handcode the entire form using only a single "Custom Code" event in the "OnLoad". The form includes the submit button, and the form displays properly but the sumbit does not do anything....

1. Do I have to use form tags?
2. If so, what is the action?
3. If NOT, how do I get the form to submit (there is nothing at all in the "Preview" tab.) ?

Thanks
MrFitz
BTW... I thought I had posted this reply yesterday, but there is no sign of it??????
GreyHead 12 Jul, 2013
Hi MrFitz,

You can either use the ChronoForms <form> tags or add your own. If you add your own you *must* turn off the ChronoForms tags in the form General tab.

If you are outputting from the On Load event then I think that you need to set the action Mode to 'View'. Personally I do any data-processing in a Custom Code action in the On Load event; then use a Custom Element element in the Preview box to do the actual output.

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