Forums

How to store repeater data?

Eddi Bournell 02 Mar, 2021
I think , I have to use the "json Encode" option in the save-data-action. But....how's the syntax??
cruser 13 Apr, 2021
A complete tutorial on saving repeater field data would be helpful!
Eddi Bournell 13 Apr, 2021
Well folks, here is what I found out:
In my example I use a database with two fields. The field "customer" should be longtext. The repeater-fields are stored here in JSON-format.



​[file=13813]Repeater_demo_EB.cf7bak[/file]
.
cruser 20 Apr, 2021
What an AWESOME display, Eddi! Thanks a ton for that! The data is now stored in field named "customer" as:

{"1":{"name":"100","address":"101","phone":"102"},"2":{"name":"103","address":"104","phone":"105"},"3":{"name":"106","address":"107","phone":"108"}}

How do you get that to display using something like {var:Article.customer}?

When I call the data into my HTML view using {var:Article.customer} it displays exactly as {"1":{"name":"100","address":"101","phone":"102"},"2":{"name":"103","address":"104","phone":"105"},"3":{"name":"106","address":"107","phone":"108"}}.

I think what I am after is a table to display the repeated data. The first column: name, second column: address, the third column: phone and each row show the data above.

Eddi Bournell 26 Apr, 2021
Answer
Tataaa! Here is the solution : How to read repeater-data into a Table-List:
My Source Table is: #__aa_adressbook (Sorry for that writing -mistake , but it`s the same table like in the first Save-Data-Example) The field "id" is just a number, "customer" holds the json-data.
  1. ReadData Action -> Label: Read Repeater Data , Name: read_data_repeater, Model Name: Addressbook
    Advanced Settings -> select: Special Fields -> Data Path: Addressbook.customer (model.json-fieldname)
    Processing Function: Decode JSON
    Dont forget to set the Behaviors-Option Data: Populate Fields
  2. Switch to Views -> under "Pageblocks" find Table List and
    Drag it to the Views-Section
    Edit Table List -> choose the Read-Data-Action "read_data_repeater"
    Into the Table Columns you have to insert the Path to the DB-Tablefields: Model.fieldname.obj.key
    e.g. : Adressbook.customer.1.name gives the customer-name of the first row.
  3. Under "Advanced Settings" you can style the table-output.
2.

3.

The Result🤣:
[file=13830]Read_Repeater_Demo.cf7bak[/file]
Hope, you are successful. It took me some hours to dig for all informations
Eddi Bournell 26 Apr, 2021
Sorry, I can`t delete the double uploads. Should only be 4 pictures.
You need to login to be able to post a reply.