Buy Now
Sign in

Error on Array when using multiplier

chekwan , March 07 2017
C
chekwan
Hi..

I try to use the multiplier function. and I have followed all the instruction here:
https://www.chronoengine.com/faqs/70-cfv5/5245-how-can-i-use-the-multiplier-in-cfv5.html
https://www.chronoengine.com/forums/posts/f5/t98601.html

I also want my submission store in database..



but when user submit the form, an error regarding array appeared. here my screenshot of the debugger:


or you can see in my attachment


I also attached my backup form, so you can see my setting..


Please help to solve this problem.
GreyHead
Hi chekwan,

The first PHP Notice (which may not be a problem) is from a line in your Custom Code - you might want to take a look at that.

The remainder are because the Handle Arrays action is designed for use with simple single-level arrays from Checkbox groups and Multiple Drop-downs. It can't handle correctly the multi-level arrays created by a multiplier. If you add a Debugger action near the beginning of the form On Submit event you will see the data that is being submitted.

You want to keep the Handle Arrays for the two CheckBox groups - so add those names into the box in the action settings.

The best way of handling the Multiplier data is to use a second table for the repeating name mail and phone and save separate records there for each set of values linked to the main table by the record id.

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

The first PHP Notice (which may not be a problem) is from a line in your Custom Code - you might want to take a look at that


Yes i have put the custom code to send the data to the external system.


The best way of handling the Multiplier data is to use a second table for the repeating name mail and phone and save separate records there for each set of values linked to the main table by the record id.



Can you guide me in details to solve this problem.?
GreyHead
Hi chekwan,

Please try using this section from the FAQ
You will probably want to use two tables to save this data. One main one for the form data that is not in the multi field array and a second one for the multi-field records. You will need to link the two together by saving the main data first, then getting the Primary Key of that record - usually the id or cf_id - that ChronoForms will have added to the $form->data array. Add this to the mult-field data and use a second DB Save action with 'Multi save' and 'Save under model id' set to yes.

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

Based on the FAQ instruction:

1- Create table for main information
2- When view the table structure, uncheck for the multiplier content
3- Save
4- Create another table for additional multiplier information.
5- Check the multiplier and uncheck others (except cf_id)
6- Link both table using Multi Save.


It is correct.?
GreyHead
HI chekwan,

Yes, apart from step 5 - what you need to do there is add a custom code action that will add the new cf_id value to each of the entries in the multiplier array.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rtobias
Not to hijack what may now be an old thread, but would it be possible to provide an example of what the model's array should look like? I'm just having trouble visualizing it atm. Also, if I have my multiplier field something like AdditionalNumbers_##_number, should I be keeping it as that in the table structure, or should I be renaming it to something like AdditionalNumbers?
Randy
GreyHead
Hi rtobias,

Please see the section Setting element names and ids in this FAQ

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
R
rtobias
Hi Bob. I looked at that first. I guess my brain is just failing at connecting how the array needs to be structured to go into the db, and the multiplier example/demo you guys have for us doesn't include saving to the db.

For example, if my field is named AdditionalNumbers_##_number, i don't know if i need a repeater to construct the array properly to go in the db, or is it just $this->data["AdditionalNumbers"
  • ["number"] and the multi save will just save them all automatically. I know we need a cf_id, but didn't know if i need to manually create a new array to be used with saving via model along the lines of:
    $Data2 = array();
    $Data2["cf_id"] = $this->data["id"];
    $Data2["AdditionalNumbers"] = $this->data["AdditionalNumbers"];
    I'm assuming even though i name my field $AdditionalNumbers_##_number, cf automatically converts the name into the multi dimensional array.

    Sorry I'm being so dense. The worst part is that i know I've set this up correctly in the past.

    Slightly related, if i have two multiplier fields (numbers and fax_numbers), it's fine to use the same replacer (##)? There can be different number of numbers and fax_numbers, so i can't put both fields in the same multiplier container.
    Randy
    GreyHead
    Hi rtobias,

    The example in the FAQ will save into a database table using the Multiple option to save the multiplier elements. It's hard to be more specific as I can't work out form your posts what you are trying to do or how you want to save the repeater data.

    I'm assuming even though i name my field $AdditionalNumbers_##_number, cf automatically converts the name into the multi dimensional array. No it doesn't - you need to use array names like those in the FAQ.

    if i have two multiplier fields (numbers and fax_numbers), it's fine to use the same replacer (##)?I've never tried but I would use different keys to avoid any doubt e.g. #a# and #b#

    Bob



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