Cannot link DB Multi Record Loader and Checkbox Array

mapme 24 Feb, 2012
Hello,

I have successfully integrated a Multi Record Laoder into my form, and going by the HTML the data is displaying correctly. I am pulling in values, ids and name tags dynamically:


<?php foreach($form->data['GroupLoader'] as $detail): ?>
<input type="checkbox" name="Group[<?php echo $detail ['cf_id']; ?>]" value="<?php echo $detail ['GName']; ?>" /><?php echo $detail ['GName']; ?><br />
<?php endforeach; ?>


This loops through all values in the lookup based on the GroupLoader tag.

However I have linked this to a database table, and the data from checkbox values will not add to the table. The row adds correctly for all fields except the values from "Group", above.

Maybe I am staring at this too long - but can you please let me know if you spot anything amiss.
Ideally, I will pull in a comma delimited list of values that are ticked from the checkbox list.

In the Events section of the form I have "DB Multi Record Loader" appearing above the "Show HTML" event. I have swapped these around, but no joy!
mapme 24 Feb, 2012
Poblem solved!
Add an "ArrayHandler" to the onSubmit pane... before the DB Save function!
Working perfectly now.
GreyHead 25 Feb, 2012
Hi Mapme,

Is this a CheckBox group - all sharing the same name; or a group of single Checkboxes each with different names?

If it's a CheckBox Group then the code will need to be something like this with an extra [] after the name:
<?php foreach($form->data['GroupLoader'] as $detail) {
  echo "<input type='checkbox' name='Group[{$detail['cf_id']}][]' 
    value='{$detail['GName']}' />{$detail['GName']}<br />";
}
?>
mapme 25 Feb, 2012
Hi Bob,

I am a little confused now.
Yes, you are correct that it is a checkbox group. So ultimately I am trying to load an array of checkbox values, and these will be read from the Group field in the database row.

Based on your suggestion, I am assuming this is reading the data from Model ID, called "GroupLoader".
I just can't get this to work! The rows in the database exist as "Group1, Group2, Groups3", but these will not load.

I have moved from a multi record loader to a single record loader as there are multiple rows of data coming from a single database row (ie, the Group array!). That took a while to sink in.

The problem for me is that I do not need the Model ID for any more of this form. I am unsure how to use the Model ID loader from dropdown selections (maintain select=selected on dropdowns for example).

Can I add two record loaders? One without the model loader, and one with the model loader for the array?

I've attached how the form *should* load, and I've also attached for form work to date.
Any advice would be greatly appreciated on this.

Pulling my hair out!

Thanks a lot,

Brendan C.
mapme 25 Feb, 2012
Form work attached here!
mapme 26 Feb, 2012
Hi Bob/Group,
Pleas ignore the post here.
The logic will not work correctly in any event at the moment for me.

Process as follows:
1. Members register for groups in a data entry process: Group 1, Group 2 and Group 3.
2. If they select 2 of these groups then they are added to a table in a comma delimited structure.
3. There is then an edit procedure which is using Chronoforms record loader to call values from this table. The problem here is the original FULL table values will not be available - just the two options selected by the user.

I've got around this by hard coding in options for the user, and changing the original table structure to include a possible Group ID for each value. Therefore there is now a column for Group1, Group2 and group3, wtih true/false values for each of these.

not as neat, but will get me out of trouble here.
Sorry for wasting time.

Good learning curve with CF4 and the various record loader options though.
Brendan
GreyHead 26 Feb, 2012
Hi Brendan,

OK - good luck :-)

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