Answer the question
In order to leave comments, you need to log in
How to display an array in a REST application through ActiveDataProvider?
There are two models: Text and Tags. There are connections between them. The REST application's response to a request for the Text model should be something like this:
"items": [
{
"id": "1",
"name": "Title",
"desc": "Description",
"active": 1,
"tags": [ // Это данные из модели Tags
{
"id": 1,
"name": "Test tag"
}
]
},
…
]
return new ActiveDataProvider([
'query' => $modelClass::find()->with('tags')
]);
Answer the question
In order to leave comments, you need to log in
I read the doc inattentively :-( It turns out that all you had to do was pass the expand=tags GET parameter in the request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question