CodeGeek
(Mk K Greek)
December 2, 2014, 2:54am
1
Hello everyone,
I was try to create a new ActiveDataProvider in one of my actions and then i got this error:
"Unknown Property – yii\base\UnknownPropertyException",
"Setting unknown property: yii\data\ActiveDataProvider::0"
The case now i had two table:
1.table project.
2.table task that had a foreign key for project.
My relations are setup between the two tables. and everytime i want to create an action that has an ActiveDataProvider in ProjectController to fetch some information from task table i got this erorr.
I would like to hear your solutions about this issue, thank you and have a great day.
Can you share your code, so yii members can easily help you!
CodeGeek
(Mk K Greek)
December 2, 2014, 6:16am
3
this is the code for my action project controller that i got the error with it:
public function actionViewtasks($id)
{
$rawData = Task::find()->where(['project_id'=>$this->findModel($id)->id])->all();
$taskDataProvider = new ActiveDataProvider($rawData,[
'sort'=>[
'attributes'=>[
'task_id','task_name', 'task_start', 'task_end', 'task_period','project_id','user_id'
],
],
'pagination'=>[
'pageSize'=>5,
],
]);
return $this->render('viewtasks',[
'model' => $this->findModel($id),
'taskDataProvider'=>$taskDataProvider,
]);
}
this is the code for my action project controller that i got the error with it:
public function actionViewtasks($id)
{
$rawData = Task::find()->where(['project_id'=>$this->findModel($id)->id])->all();
$taskDataProvider = new ActiveDataProvider($rawData,[
'sort'=>[
'attributes'=>[
'task_id','task_name', 'task_start', 'task_end', 'task_period','project_id','user_id'
],
],
'pagination'=>[
'pageSize'=>5,
],
]);
return $this->render('viewtasks',[
'model' => $this->findModel($id),
'taskDataProvider'=>$taskDataProvider,
]);
}
Try this - http://www.yiiframework.com/doc-2.0/yii-data-activedataprovider.html
CodeGeek
(Mk K Greek)
December 2, 2014, 8:31am
5
It fixed the problem, thank you so much and a have a great day