get origData with joined repeated groups

jolle

Member
Hello,
I am trying to write a custom form submission email template to send a message when an entry was added or updated. For updated records it should show old vs. new value.
I found this thread providing a good start:
http://fabrikar.com/forums/index.php?threads/update-mail-script-1-5-3-0.37994/#post-190992

Now my problem is that I have 2 repeated groups in my table.
The following code in a PHP Email Template only returns the first entry of each repeated group.
PHP:
$origData = $formModel->getOrigData();
$origData = JArrayHelper::fromObject($origData[0]);
echo var_dump($origData) ;

This was already discussed here:
http://fabrikar.com/forums/index.ph...-entry-in-repeatable-group.38199/#post-192450

Is there another way to get the original data?
The current data can also be retrieved through
PHP:
$elementData = $formModel->getElementData('tablename___elementname');

Is it possible to change getOrigData() function to return repeated groups correctly?
Or to implement a function $formModel->getElementOrigData()?

BR,
J?rn
 
Hi, a bit an old subject but I experiment the same problem, is there a way to retrieved these data for a repeated group?
Thanks.
 
I use this code in php form plugin.

PHP:
$origVal = $formModel->_origData;
foreach ($origVal as $key => $value) {
    $your_rowID[$key] = $value->table_name___id;
    $your_element1[$key] = $value->table_name___your_element1;
    }
echo '<pre>your_rowID values: ' . var_export($your_rowID, true) . '</pre>';
echo '<pre>your_element1 values: ' . var_export($your_element1, true) . '</pre>';
I hope this help.
 
Nope, still the same problem.
My repeated group has 2 records:
upload_2016-5-20_9-31-44.png
and here is the result when I try to retrived the 'origdata' ( I changed the first field value):

your_element1 values: array (
0 => 'lettre impots 23',
1 => 'lettre impots 23',
2 => 'lettre impots 23',
3 => 'lettre impots 23',
4 => 'pv ag 4',
5 => 'pv ag 4',
6 => 'pv ag 4',
7 => 'pv ag 4',
)
 
To test your code I wrote this:
Code:
$origVal = $formModel->_origData;
foreach ($origVal as $key => $value) {
    $your_rowID[$key] = $value->table_name___id;
    $your_element1[$key] = $value->identitee_fichiers_pv_ag___description;
    }
echo '<pre>your_element1 values: ' . var_export($your_element1, true) . '</pre>';

I was using previously :
Code:
$origData = $formModel->getOrigData();

And to test :
Code:
echo $origData[0]->identitee_fichiers_pv_ag___description;
echo $origData[1]->identitee_fichiers_pv_ag___description;
echo $origData[2]->identitee_fichiers_pv_ag___description;
echo $origData[3]->identitee_fichiers_pv_ag___description;
echo $origData[4]->identitee_fichiers_pv_ag___description;

And the result is:
lettre impots 23lettre impots 23lettre impots 23lettre impots 23pv ag 4

The 2 methods show the same results, I was expecting in your caes:
0 => 'lettre impots 23',
1 => 'pv ag 4',

and in my case:
lettre impots 23pv ag 4

I don't see where can be the error in the code.

This is working when the element are not in a repeating group.
 
To summarize, we've done a lots of tests with Startpoint (in PM, thanks to him for the time he spent), and the result is that it works for him but not for me, and I really don't know why :) I'm gonna think about it...reinstall...github... I don't give up :)
 
Are you accounting for the fact that as you have two repeats, there will be X * Y rows (where X and Y are the number of repeats in each group).

So if you have repeats in each group, you'll have 25 rows, which if you looked at the PK values for the two groups would be ...

1,1
1,2
1,3
1,4
1,5
2,1
2,2
2,3
2,4
2,5
3,1
3,2
3,3
3,4
3,5
4,1
4,2
4,3
4,4
4,5
5,1
5,2
5,3
5,4
5,5

-- hugh
 
Hi Hugh,
I'm not sure to understand, you mean X is the master record and Y the detail record ?
I have 5 groups, in each group I have 2 fields ( Description and File) .
I only have 1 master record ( can't have more).
I access to 'old' data by
Code:
$origData = $formModel->getOrigData();
 
The origdata will (I think) be formatted without "merging". So your repeat groups will be repeated as multiples. The way they would be shown in list view if you don't set "merge repeats".

-- hugh
 
Well, I can't figure out how it works to get the values for the joined tables, it's not the most important by now, so I'll work again on that later. Thanks for your help.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top