It seems I am having a problem passing the right format to a widget. Might be trivial, but i cannot figure it out.
I am using the code to try to display some data referenced in a model with a foreign key ($model has a one to many foreign key to "referencedTable" data).
yes. along those lines, but the problem here is that the referencedTable is a one-to-many relationship from my original table.
Basically it’s something like this:
table1 : members table
table2: posts table (many for each member)
so in $model i have one record from the table1 (members table, details of one author)
in $model->referencedTable, through the model methods generated by giix i have all posts from table2 (posts table).
and I want to display the posts, in the member view, using a ListView widget.
I know i can do something like
$data = referencedTable::model()->findAll();
and add a condition to get only the posts for the member I am displaying, but since i already have all the information in $model->referenceTable it seems redundant to ask for it again, right?
We don’t give an array of data directly to a CListView. Instead, we give it a data provider which will provide an array of data. That’s how the CListView is designed.