k0432
(Johocn)
1
我的controller是这样设计的
$model=new Purchorders;
$locations=new Locations;
$suppliers=new Suppliers;
$locationscount=$locations->count();
$supplierscount=$suppliers->count();
$this->render('create',array(
'model'=>$model,
'locations'=>$locations,
'suppliers'=>$suppliers,
'supplierscount'=>$supplierscount,
'locationscount'=>$locationscount,
));
在view中想使用$locationscount这个变量,代码如下,无法获取想要的值,结果一片空白
<?php echo $locationscount; ?>
k0432
(Johocn)
2
问题已解决:原因是我的view是creat下的子页,需要再次传参数
<?php echo $this->renderPartial(’_form’, array(‘model’=>$model,
'locations'=>$locations,
'suppliers'=>$suppliers,
'supplierscount'=>$supplierscount,
'locationscount'=>$locationscount,)); ?>
这样就好了
k0432
(Johocn)
3
问题已解决:原因是我的view是creat下的子页,需要再次传参数
<?php echo $this->renderPartial(’_form’, array(‘model’=>$model,
'locations'=>$locations,
'suppliers'=>$suppliers,
'supplierscount'=>$supplierscount,
'locationscount'=>$locationscount,)); ?>
这样就好了