如何解决警告 htmlspecialchars() expects parameter 1 to be string, object given in yii1?
How to solve warning htmlspecialchars() expects parameter 1 to be string, object given in yii1?
我的控制器代码是 below.what 是这段代码中的 htmlspecialchars()。
public function actionAdmin()
{
$model=new TaskAssignDevloper('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['TaskAssignDevloper']))
$model->attributes=$_GET['TaskAssignDevloper'];
$this->render('admin',array(
'model'=>$model,
));
}
我的查看文件代码是这样的
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'task-assign-devloper-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'teamleader0',
'task0.title',
'developer0.username',
'description',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
在你的视图文件中,你建立了关系。如果关系与另一个 table 不匹配,那么它会给出这种类型的错误。
例如。您正在将任务分配给开发人员并将开发人员 ID 存储在分配任务 table 中,但是在您拥有所有开发人员列表的用户 table 中找不到该开发人员 ID。
yii 2 教程:- Yii 2 tutorials
我的控制器代码是 below.what 是这段代码中的 htmlspecialchars()。
public function actionAdmin()
{
$model=new TaskAssignDevloper('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['TaskAssignDevloper']))
$model->attributes=$_GET['TaskAssignDevloper'];
$this->render('admin',array(
'model'=>$model,
));
}
我的查看文件代码是这样的
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'task-assign-devloper-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'teamleader0',
'task0.title',
'developer0.username',
'description',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
在你的视图文件中,你建立了关系。如果关系与另一个 table 不匹配,那么它会给出这种类型的错误。
例如。您正在将任务分配给开发人员并将开发人员 ID 存储在分配任务 table 中,但是在您拥有所有开发人员列表的用户 table 中找不到该开发人员 ID。
yii 2 教程:- Yii 2 tutorials