Forums

Repeater with user entered repeater counts

Elita- 28 Feb, 2019
Hello, I created a registration form where user can enter the number of participants on the first page of Multipage form;
On the next page the repeater shows Participants detail data entries:



For the repeater area I defined Data provider {data:rep}, where rep is calculated source of the data set used to repeat the content (i used javascript function to subtract 1 from the Number of Participants to get the right count);


Repeated fields have been defined as follows: rep[{var:area_repeater52.key}][Uzv]




Save data is in the loop action and is defined as follows:








The debug shows following:

Array
(
    [option] => com_chronoforms6
    [chronoform] => multipage-repeater-copy
    [event] => submit
    [rep] => Array
        (
            [0] => Array
                (
                    [Uzv] => rep1
                    [Vards] => rep1sur
                    [email] => rep1email
                )

            [1] => Array
                (
                    [Uzv] => rep2
                    [Vards] => rep2sur
                    [email] => rep2email
                )

            [2] => Array
                (
                    [Uzv] => rep3
                    [Vards] => rep3sur
                    [email] => rep3email
                )

        )

    [button57] => 
    [Itemid] => 
    [skaits] => 3
    [button56] => 
)

[save_data22] => Array
        (
            [data] => Array
                (
                    [Uzv] => rep3
                    [Vards] => rep3sur
                    [email] => rep3email
                    [created] => 2019-02-28 18:59:22
                    [user_id] => 0
                    [skaits] => 3
                    [rep] => Array
                        (
                            [0] => Array
                                (
                                    [Uzv] => rep1
                                    [Vards] => rep1sur
                                    [email] => rep1email
                                )

                            [1] => Array
                                (
                                    [Uzv] => rep2
                                    [Vards] => rep2sur
                                    [email] => rep2email
                                )

                            [2] => Array
                                (
                                    [Uzv] => rep3
                                    [Vards] => rep3sur
                                    [email] => rep3email
                                )

                        )

                )

            [_success] => Data saved successfully
Unfortunately, as a result, DB entries have 3 similar entries from the last (3rd) repeater data entry.
What is wrong here? Thank you in advance -
Elita

P.S. And yes, first time i run the form I got the DB error - with missing Array column, so I created that.
healyhatman 28 Feb, 2019
Turn off Auto Manage the Data Table, then you will need to fix your data table because if you look I bet it will have incorrect columns. It doesn't like repeaters and array-named fields.

Then remove the "data source" option from your save data action and manually add each field you want to save to the override on insert option. Like this
Uzv:{var:loop_event21.row.Uzv}
Vards:{var:loop_event21.row.Uzv}
etc
Elita- 04 Mar, 2019
Thank you, healyhatman for your reply.
Tried to implement your advice, no w I get all data entered in all rows.:
If I enetered 2 repeater rows with fofollowing:
Vards [0] - "TESTS1"
Vards[1] - "TESTS2"

i get 2 rows with following similar entries: ["TESTS1","TESTS2"]

however i need TESTS1 to be entered in one row, TESTS2 in other.

Any suggestions?
healyhatman 04 Mar, 2019
What do you mean I'm a bit confused sorry. That's an array with two entries what's the problem?
Elita- 04 Mar, 2019
ok. I did what you suggested -
switched off "Auto manage the data table" and added three entries in Data override on Insert:

rekv_uzv:{var:loop_event56.row.rekv_uzv}
rekv_vards:{var:loop_event56.row.rekv_vards}
rekv_kods:{var:loop_event56.row.rekv_kods}

Now, when I fill in the fields inside the repeater area :



I get the following DB entries:

healyhatman 04 Mar, 2019
What have you named your fields and what sort of fields are they.
Should be for example
Group[{var:area_repeater#.key}][uzvp]
And the event loop data source should be {data:group}
Elita- 04 Mar, 2019
ok. got it. switched wrong toggle😀
Should have switched off "Auto save fields" instead of "Auto manage the data table".

If I understand correctly, now i have to write in all the fields to be written in that table - even those ones outside the repeater .
healyhatman 04 Mar, 2019
Switch off both, they're both terrible. You'll have to make your table yourself which will be better anyway. You might need to manually clear the cache PHP file in the /cache folder afterwards.
Elita- 04 Mar, 2019
now i got bunch of sql errors😟
what would be the correct syntax for Data override on Insert if I had three types of data to be entered:

1) repeater fields with the loop action would be e.g. rekv_uzv:{var:loop_event56.row.rekv_uzv}
2) fields outside the repeater would be
fieldname:
or
fieldname:{var:fieldname}
or
smth else?
3) automatic fields like ip, uuid - before I had this - uuid:{uuid:}, now i get error - 1048 - Column 'uuid' cannot be null

:(
Elita- 04 Mar, 2019
what if i wanted to save data outside the repeater in one DB table and Repeater data in other DB table+some fields that are saved in the first table?
with that automatic thing switched on i had like this -
epasts:{var:save_data51.epasts}
Elita- 04 Mar, 2019
thank you, figured everything out.
This topic is locked and no more replies can be posted.