How to get repeated data from previous record?

bea

Active Member
Hi,
I need some help with a form PHP script (OnBeforeProcess) to get repeated data from previous record.

There are following elements:
fab_24h_focus_212_repeat___id
fab_24h_focus_212_repeat___parent_id
fab_24h_focus_212_repeat___theme
fab_24h_focus_212_repeat___description
fab_24h_focus_212_repeat___carer
fab_24h_focus_212_repeat___department

I'm a little lost at the moment....
Thank you in advance

bea
 
What do you mean by ”previous record"?

E.g. if you have a main table id of 8 and you want the repeat data related to main table id of 7? Or something else?
 
Hi,
yes, that's what I mean.
I want that Data from a repeated group (ID 7) will go to a new next record (ID 8).
Thank you
 
It can be a bit tricky to pre-fill repeat group data. Here's an old thread with Hugh's answer. Option 2 is probably more reasonable approach.

You could also create a separate custom "add" button in list header (custom list template), attach a click event to it in list_xx.js and then with user ajax (in user_ajax.php) you would add the main table record and related records from previous id. And in ajax done function redirect to a newly added form record. This method is what I've used myself.

With Hugh's approach, as a last step in the form PHP plugin, you need to get the current rowid, sustract one, get the related data for that rowid and insert to related table. Let me know if you will get stuck with the code. Here are some examples if needed:
https://fabrikar.com/forums/index.php?wiki/php-common-tasks/
 
Last edited:
onBeforeProcess - occurs at the start of a form submission, before the posted data has been assigned to the form model, but after the form has been validated

If I understud your Q every time you save the form you will add related data from previus record?

If you meant when create a new record then it is not that hard.
 
In one of my old app I did somethig similar but onAfterProces so after current record was added in db. And in repeat group I have one more element xx_repeat_yy__parent_id_old. You dont want to to drag all repeat data from ID 1 to ID n. And then just do some querys to grab last ID repeat and insert data to db repeat table.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top