There is a table and a related table in which the headers and values of arbitrary fields are stored.
One element of the main table can have many additional fields. Link id
( tours.id->tourfields.tour_id
). How to display them in a GridView
? The name and value of the field in the base table. GridView
displays only a certain number of columns?
With a known number and names, you can manually prescribe them, and if the number and headers are unknown in advance.
GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'name', 'qadult', 'qchildren', 'qbaby', //Тут добавить еще произвольное количество столбцов с //заголовком и значением из таблицы tourfields. ['class' => 'yii\grid\ActionColumn'], ], ]);