Repeat Group row id in php

Status
Not open for further replies.

Fred04

Member
in php I would like to write some code in a display element

It would look like:

Code:
return $data[join][133][dailysubqa___idsubques][$i]

how can I set my variable $i with the id of the repeat group? (ie 0 for the first repeat group, 1 for the second....)
 
here is my updated code:

Code:
return $data[join][133][dailysubqa___idsubques][(int)$repeatCounter];

pb: the (int)$repeatCounter always return 0 instead of the repeat group id.

ps: I'm using this php code in a 'display' plug-in
 
When you do a return it immediately returns what you tell it....

So I believe that
Code:
return $data[join][133][dailysubqa___idsubques][$i];
Will return just the first item of the array and not 0,1,2,3

What is the result of

Code:
echo '<pre>'; print_r($data[join][133][dailysubqa___idsubques]);exit;
 
it shows

Array
(
[0] => Invoice of type A
[1] => Invoice of type B
[2] => Invoice of type C
)

but as explained by Hugh, I tried to use the $repeatCounter variable (I'm in a repeat group).. but without too much success.

When I use in my display plug-in:
Code:
return (int)$repeatCounter;
I got 0 for each of my 3 repeat groups
 
So you want to return all three values in the one element?

If so then something like this?


Code:
$results = '';
foreach ($data[join][133][dailysubqa___idsubques] as $result) {

    $results .= $result . ' - ';
}
echo '<pre>'; 

return $results;



Apologies if I've got this wrong.
 
no,

I want:
'invoice type A' in my first repeat group
'invoice type B' in my second repeat group
'invoice type B' in my third repeat group

that's the reason why I want to use
Code:
return $data[join][133][dailysubqa___idsubques]
[(int)$repeatCounter];

but without success...
 
ok, I read it all back very very slowly!

I didn't even know about the $repeatcounter variable!!!

I have to be honest and say I don't know how to do this, as I can't get my head around your layout and what if any joins are involved.
 
Status
Not open for further replies.

Members online

No members online now.
Back
Top