I have a form that uses a repeater area, and want to save it in a database table. When I use the Create Table function, the default column names include the reference to the iteration key, but the data does not save. I cannot find anything in the manual or forum that explains how you save the repeater data. I assume that there is no option to normalize the data in multiple tables.
Do I I simply need to create columns for each iteration? That is, if my form has firstname{var:area_repeater10.key}, lastname{var:area_repeater10.key}, phone{var:area_repeater10.key}, I need to create columns for firstname1, lastname1, phone1, firstname2, etc?
Thanks!
Hi farscape,
The most common way to save repeated data from form is to use a second table linked to the first by the new record id.
You can use multiple columns but they is harder to read and re-use; or you can json-encode the data and save it to a single text column - that's simple to do but not so easy to search later.
Bob
Thanks NickOg and Bob. I'm afraid that I'm not up to the skill levels that you are and am up against a deadline, so I am having to compromise this time around and limit the output to an email, but that's leading me to another question that I hope is within my abilities. I'm posting it separately because while related, it's different.
Thanks again.
Hi farscape,
Using a second table does take a little work to create the table but there is no coding or special knowledge required.
Bob
I don't mind the work. So does CF6 handles the joins automatically? Is there any documentation on how you can set CF6 to write the repeater area fields to the second table?
Bob, Sorry to be such a dolt, but how do you capture the new record ID? I can't find anything in the manual or the forum.
Max provided the solutions in a separate thread: In the Save Data action that is inside the Loop Event action, turn off "Auto Save Fields". Thanks Max!
Max provided the solutions in a separate thread: In the Save Data action that is inside the Loop Event action, turn off "Auto Save Fields". Thanks Max!