V
V
Vyacheslav_Shilov2020-07-04 18:10:38
Yii
Vyacheslav_Shilov, 2020-07-04 18:10:38

Yii1.1. How to fill a table cell with multiple values ​​in CGridView? Or how to make multiple cells of one column per cell of another?

Given: the two tables of the table "firsts" and "seconds" are in the relationships "firsts" has_many "seconds" by the key "first_id".
I am trying to display the data of both tables in a CGridView. I want all the cells of the "name" column from the database to be placed in the "Seconds" column of the CGridView, and not just one. How to do it?

$Firsts = new CActiveDataProvider('firsts', array(
          'criteria'=>array(
              'with'=>array('seconds')
            ),
        ));
      $this->widget('zii.widgets.grid.CGridView', Array(
          'dataProvider'=>$Firsts,
            'columns'=>Array(
                'name',
                'phone',
                array(
                    'name'=>'Seconds',
                    'value'=>'$data->seconds[0]->name'
                )
            )));

Does CGridView basically make the contents of one CGridView table cell into multiple table cells from the database?
5f009b5f203ee021006015.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question