Store a repeatable group values

RobertG

Member
Hi,

I'm working on a form using some groups. Only one group is repeatable, so its data will be stored on several rows, but what will happen to the other data of the form, if the repeatable are stored in the same table? Will they be duplicated?

And if I store them in another table, how to join the main table row and the second table, using the id of the first one?

Thanks for you help!

PS More explanations:
The form is used to add unique data to an A table (course, accommodation, first and last name, etc.).
One can select an option and an activity for the week (stored in the tabke B).
If the stay is longer than a week, the repeatable group allows to add option and activity for the second week, etc. and I don't know how the id of the row in table A can be stored in the rows of table B.
I have read the repeatable group wiki page.
 
Last edited:
You can create new group in your form, move the elements there which you want to be repeatable and set this group's "Repeat" to "Yes" in group settings.

Now Fabrik automatically creates a new table something like your-main-table-name_xx_repeat.

And the relation will be maintable.id to repeattable.parent_id

Or if you use existing table as your repeat table, make sure the setup / relation follows the same schema.
 
Thanks juuser.

The repeatable group was already created with two dropdown lists from two tables (options and activities) and the selected values now need to be stored in another table (#__fb_stay_week : id_stay, id_week, id_option,id_activity).

So do I need to create other elements to store the results of the selection and join them to the #__stay_week table?
id_week comes from another table #__week ('id',`date_starts`,`date_ends`,`year`)
 
If you already have the repeat table, add an hidden field element (parent_id) to this list.

Then go to your main list and add join like:
maintable.id -> repeattable.parent_id and set this join's "Repeatable" to "Yes".
 
I had this, but parent_id is null (see attached pictures).
What is my error?
 

Attachments

  • Capture d’écran 2023-07-05 163658.png
    Capture d’écran 2023-07-05 163658.png
    27.7 KB · Views: 49
  • Capture d’écran 2023-07-05 163825.png
    Capture d’écran 2023-07-05 163825.png
    15.2 KB · Views: 43
Why do you have two exactly the same join rows? What happens when you remove the duplicate?
 
I don't remember why I had two joins (I created the prototype site 3 years ago).
I deleted one line and had no changes.
 
Deleting the join won't change the db table (i.e. the missing parent ids) at this moment.
Did you try to insert something new?
 
Thanks!
I didn't find an element "parent_id" in the group :(
I created it and it works now. :)
But I didn't find how to hide it in the group tab.
 

Attachments

  • Capture d’écran 2023-07-06 083238.png
    Capture d’écran 2023-07-06 083238.png
    23.3 KB · Views: 40
If the parent_id was missing in a Fabrik created repeat group something got screwed up on your site.

Is this a site with real data or just a test site?

I would remove the list join, delete the repeat group (empty trash) and create a new repeat group.
There must be a parent_id and an id element in the repeat group (an if it's Fabrik created they will be hidden automatically).
 
This is a test site for the moment, but the structure of the table should correspond to a PostgreSQL table that will be imported when it becomes a production site.

I changed the value of "hidden" in the elements table for this element, and it works.
 
Last edited:
I would still perform the routine that troester said as you shouldn't have to manually create the parent_id. It may have not got created due to the order that you did things but you need to be confident that it's setup correctly otherwise you will have issues later on, (which could involve data loss).
 
You're right, I may try it, but I'm too scared of disorganising everything if I delete and recreate this group and its elements, which feed elements from another group.
 
I've probably done it wrong, because no "parent_id" element has been created, I had to do it manually, type "field", and it's not hidden. So I'm back to what I had when I saved.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top