Yii - how can I search by a column from foreign/related key on admin page?

后端 未结 2 1395
刺人心
刺人心 2021-01-03 13:15

In my database, I have two tables, manufacturer and plastic:

CREATE TABLE `manufacturer` (                                                                            


        
2条回答
  •  攒了一身酷
    2021-01-03 14:02

    It also works if you just use 'manufacturer_search' for the name of the column, as shown in the tutorial you mentioned above.

    widget('zii.widgets.grid.CGridView', array(
        'id'=>'plastic-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'columns'=>array(
            'name',
            array(
                'name'=>'manufacturer_search',
                'value'=>'$data->manufacturer->name'
            ),
            array(
                'class'=>'CButtonColumn',
            ),  
        ),  
    )); ?>
    

提交回复
热议问题