Forums

Need working example of saving repeater area fields to DB

farscape 27 Jan, 2018
1 Likes
Having no luck getting what I need from the forum. I need a simple example of a form that includes repeater fields and saves all repeater rows to a table. I have a simple example attached that will save the first iteration only. I'm missing something, but wherever it's documented, whether the forum or the manual, I can't find it.
Willing to pay for a simple working example I can learn from.

I've attached the backup of my attempt.
Max_admin 28 Jan, 2018
Hi farscape,

It depends on how you have named your fields inside the repeater, here is a quick example:

#1- your repeater area name is "my_repeater"
#2- your field name inside the repeater is "group[{var:my_repeater.key}][my_field]
#3- you need a "loop event" with the data provider set to "{data:group}"
#3- then a data save inside the loop event with the data provider set to {var:loop_event_name.row}

Your table fields names should match the fields names inside the repeater of course, so for this example you need a table field named "my_field"

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
farscape 28 Jan, 2018
Max,

Thanks. Using your notes above, I changed my test form as follows, but still get multiple copies of the first record, so there's still something wrong. Details below, and the backup of my test form is attached.

1. My repeater is "area_repeater10"
2. My field name is "group[{var:area_repeater10}][email]"
3. My loop event data provider is set to "{data:group}"
4. My loop event is "loop_event10". The data save inside the loop event has the data provider set to: "{var:loop_event10.row}".

When I run the form and enter two email addresses, the debugger shows two emails in the first array but only the first email in the second array.

First array:

Array
(
    [option] => com_chronoforms6
    [cont] => manager
    [chronoform] => repeater
    [event] => submit
    [group] => Array
        (
            [0] => Array
                (
                    [email] => a@b.com
                )

            [1] => Array
                (
                    [email] => b@c.com
                )

        )

    [button7] => 
    [_ga] => GA1.2.226007831.1505575861
    [_gid] => GA1.2.932653421.1517023211
    [__atuvc] => 5|49,13|50,1|51,10|3,13|4
    [d3afdd8bd0d018da056b0d2c45021e09] => RoLmsh7YjucmBnzeuAq4c3
    [ec3e5ab2c77c5e545fc9f1f89eee2121] => FNUGQ3BP4bENpu42WdolF2


Second array:

Array
(
    [save_data8] => Array
        (
            [data] => Array
                (
                    [email] => a@b.com
                    [created] => 2018-01-28 19:15:39
                    [user_id] => 204
                    [] => Array
                        (
                            [option] => com_chronoforms6
                            [cont] => manager
                            [chronoform] => repeater
                            [event] => submit
                            [group] => Array
                                (
                                    [0] => Array
                                        (
                                            [email] => a@b.com
                                        )

                                    [1] => Array
                                        (
                                            [email] => b@c.com
                                        )

                                )

                            [button7] => 
                            [_ga] => GA1.2.226007831.1505575861
                            [_gid] => GA1.2.932653421.1517023211
                            [__atuvc] => 5|49,13|50,1|51,10|3,13|4
                            [d3afdd8bd0d018da056b0d2c45021e09] => RoLmsh7YjucmBnzeuAq4c3
                            [ec3e5ab2c77c5e545fc9f1f89eee2121] => FNUGQ3BP4bENpu42WdolF2
                        )

                )

            [_success] => Data saved successfully
            [log] => Array
                (
                )

            [var] => Array
                (
                    [email] => a@b.com
                    [created] => 2018-01-28 19:15:39
                    [user_id] => 204
                    [aid] => 20
                )

        )

)
farscape 28 Jan, 2018
Ok, THIS time my form is attached.

Thanks!
Max_admin 29 Jan, 2018
Answer
Hi farscape,

It looks like the "Auto save fields" setting causes the problem when its enabled for repeater fields, please disable this setting either in the "save data" action or for the fields inside the repeater and try again!

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
farscape 30 Jan, 2018
1 Likes
Thanks Max. That did it! turning "auto save fields" in the Save Data action did the trick.
This topic is locked and no more replies can be posted.