autofill in repeat group

maxxxweb

Member
Hi,
I have a problem with the Autofill plugin. I applied the plugin in repeat group but I get an error: "Uncaught TypeError: Cannot read properties of undefined (reading 'element') at Object.lookUp (autofill-min.js:3:2597)". Looking at the file line I find the error line is: "elid: t.element.id". The plugin is used to load data from a table in jin with the main one.
Can anyone give me some help?
Thank you
 
This has already be fixed for the next release (see changelog) but I didn't test in a repeat group.
Can you try
upload_2023-6-28_9-54-54.png

to see if this fix is working also for repeat groups?
Set Fabrik Options/Debugging Allow Fabrik Debug = Debug JS to run the uncompressed autofill.js
 
Thanks!
I no longer have the error and the data is loaded but only the last record of the 2 in the table. The repeated group is not created, only a single group remains where the last record in the table is loaded. Thanks again
 
Autofill is for one record only
Observes a specified field and looks up first matching record with the same data, then asks if you want to pre-fill in the form with that data
What do you want to fill when?
 
I have two joined tables and the second table has a repeating group. I would like to preload the table data into the repeating group of the form. I thought of modifying the form template, the "default_repeatgroup_table" file, creating a query that populates the repeated group. I have the problem of populating when there are multiple rows in the table why should I create as many repeating groups as there are rows in the query.
Thank you
 
Fabrik doesn't support nested repeat groups (so if your join is already set to repeat...)
But depending on your setup:
Did you try to use a form php plugin "onLoad"?
 
Hi I tried with a php script on onload, here is the code:

Code:
<?php

use Joomla\CMS\Factory;
$db = FabrikWorker::getDbo();
$user = Factory::getUser();
$app = Factory::getApplication();
//$utente = $user->username;
$utente = $user->get('username');

//$username = $data['allegato_b___username'];
//$username= {my->username};
//var_dump($user);
//exit;
//echo "<pre>";print_r($utente);exit;

if ($user != '')
                                {
                 
                         $db = FabrikWorker::getDbo(false, 2);
                      $db->setQuery("SELECT `cognome`,`nome`,`luogo_di_nascita`,`stato_civile`,`relazione_di_parentela`,`inabile`, `id_h1`, `username`, `id` FROM `nucleo_familiare` WHERE Username='$utente'");
                                           
                                            $db->execute();
                                            //$results = $db->loadObjectList();
                                            //$results = $db->loadResult();
                                            //$row = $db->loadRow();
                                            //$row = $db->loadRowList();
                                            $row = $db->loadAssocList();
                                            //print_r($row);exit;
                                            //$aff=$row['11'];
                                            //print_r($aff);exit;
                                            //echo "<pre>";print_r($row);exit;
                                            //$formModel->updateFormData('allegato_b___afferenza_organizzativa', $row['11'], true);
                                           
            //$data['allegato_b___afferenza_organizzativa']=$row['11'];
                               
                                           
        //dati anagrafica
       
        foreach ($row as $row) {
           
            $formModel->data['nucleo_familiare___cognome']=$row['cognome'];
            $formModel->data['nucleo_familiare___nome']=$row['nome'];
            $formModel->data['nucleo_familiare___luogo_di_nascita']=$row['2'];
            $formModel->data['nucleo_familiare___stato_civile']=$row['3'];
            $formModel->data['nucleo_familiare___relazione_di_parentela']=$row['4'];
            $formModel->data['nucleo_familiare___inabile']=$row['5'];
            $formModel->data['nucleo_familiare___id_h1']=$row['6'];
            $formModel->data['nucleo_familiare___username']=$row['7'];
            $formModel->data['nucleo_familiare___id']=$row['8'];
            //$formModel->data['allegato_b___username'];
            //$formModel->data['allegato_b___qualifica']=$row['9'];

            //$data['allegato_b___afferenza_organizzativa']=$row['11'];

            //$formModel->data['allegato_b___afferenza_organizzativa']=$row['11'];
            //$formModel->data['allegato_b___telefono']=$row['14'];
        }

   
       }


But it only writes the last record without creating the repeating group
 
It will not create additional repeat rows like that. At least you need to add INSERT query inside your loop something like INSERT INTO repeat_table_name...
 
Hi, I don't have to do a new insert in the table. I have the data in the table in joion and i just need to preload it to onload.
 
It seems you have already created a thread regarding the same issue: http://fabrikar.com/forums/index.php?threads/populate-repeat-group-from-table.53871/#post-281471

So the suggestions in this other thread are still valid.

It would be possible to add the variable amount of repeat table rows with javascript and then load the data via ajax call from a function in user_ajax.php, but this involves a lot of coding and I have found this method to be quite unreliable in some cases.
 
Last edited:
Yes, I had already written about this problem, I'm trying the different possible ways. Autofill or php code. Excluding the autofil plugin, all that remains is the php code but as I said I can't find a way to write in the repeated groups. Maybe you need a foreach loop with an incremental variable?
Thank you
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top