How to pre-populate _some_ fields in repeated group when adding a instance.

bggann

Active Member
I have a form with repeated groups.
In normal usage, several of the fields in the repeated group, but not all, will be the same. My users are asking if they can be pre-populated somehow. We tried the "copy" function in the repeated group structure, but it pre-populates all fields, which lead to errors when people did not correct/update some fields. Without pre-population, typing errors creep in and cause problems later (most often, a space on the end of a word due to a cut and paste).

So- I need a way to pre-populate just certain fields in the new repeated group with values from the previous repeated group. It needs to be values from the previous repeated group, and keep in mind the data has not been written to the db yet, so I cannot pull it.

One possibility is to use "copy" but then go through and clear all but the fields I want to copy. I could do that with a Java or PHP, but I can't find any way to trigger on add group.

I could also write/read to a temp file or table, but again, no way to trigger on add repeated group instance.

Thoughts?
-bg
 
There's an event which fires at the end of adding a group, which you could use in a form_X.js file ...

Code:
requirejs(['fab/fabrik'], function() {
   Fabrik.addEvent('fabrik.form.group.duplicate.end', function(form, event, groupid, repeatcount) {
      // your code here
   });
});

So you can access your element using repeatcount ... form.formElements.get('yourtable___whatever_' + repeatcount).

-- hugh
 
Ah- this is the hint I needed. It is a bit 'greek' to me, but it gives me a direction. Thanks!
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top