[Solved] Easy One, I hope... Accessing Repeated Data

mudshark79

Member
Hello Everyone, I think this one might have a short answer I'm just unable to find the answer in the wiki or through forum search:

Suppose I want to access data of elements in a repeated join from a calc element in a list view. The calc-element is not part of the repeated join but it is situated in the "base table".

Like

Code:
echo "<pre>";print_r($data);exit;
or
Code:
$data = print_r($data, true);
return $data;

Gives me the data array (we can't use $formModel->formData in a calc element, can't we?) only gives the first repeat (first screenshot), even though a

Code:
echo "<pre>";print_r($data);

repeats the data array for every repeat there is and then also reflects on the repeated data.
The Funny thing is, that

Code:
$data = print_r($data, true);
return $data;

inserted to an Eval-Tool Tip exactly gives me the $data array with the elements in the repeated parts containing the the repeated data as a comma separated list of strings (see 2nd. Screenshot).

Of course I Could get the data from the database via mysql but i just want to get my head around this so thanks for a pointer in the right direction :) .

Regards
 

Attachments

  • data1.PNG
    data1.PNG
    30.2 KB · Views: 190
  • data2.PNG
    data2.PNG
    32.2 KB · Views: 195
The issue here is that the repeat join creates individual rows in the list, so say you have a list "teachers" and a list "students", with one record "teacher = bob, students = jeff, fred and mary". Our query is going to produce a data set:

Code:
+---------+------------|
|teacher  |    student |
+---------+------------|
| bob        | jeff            |
+---------+------------|
| bob        | fred          |
+---------+------------|
| bob        | mary        |
+---------+------------|
Each calc element instance is only going to know about its own row.
If possible I'd suggest making the calc element only run on form submission, where you would have the form's entire data available to you, otherwise I think you are stuck with having to do an additional database query to grab the joined information[/code]
 
Okay, this makes it perfectly clear. Thanks for pointing that out. ;)
Will do a db-call then or maybe take a look at the java-script possibilities then.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top