我试图在 CGridView 的一列中添加一个带有 select2 扩展名的过滤器,但不起作用。
我的代码:
在查看vehculos/admin.php
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'vehiculos-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'placa',
array(
'name'=>'asociado_id',
'value'=>'Vehiculos::model()->getListNombreCompleto()',
'type'=>'html',
),
'modelo',
'color',
array(
'class'=>'CButtonColumn',
),
)));
在 vehiculos.php 模型中
public function getListNombreCompleto()
{
$nombreCompleto = Contactos::model()->findAll();
$data = array();
foreach ($nombreCompleto as $contacto) {
$data[$contacto->id] = $contacto->nombre;
}
$this->widget('ext.select2.ESelect2',array(
'name'=>'asociado_id',
'data'=>$data,
'htmlOptions'=>array(
),
));
}
显示错误 CException:
Vehiculos and its behaviors do not have a method or closure named "widget".