Display data from 3 join tables in GridView

Hi, I have 3 tables. I would like show in Reservation GridView , name movie and number_room. Now i can only show id seans. What I can do this?

and one more question. What I need do, if i would like update row and place in reservation table instead id?

I assume reservation have many seanses, otherwise all fields must be moved to reservation table.

If first variant, select all reservation with all seanses in search() method of ReservationSearch model like so:

$query = ReservationSearch::find()->with(['seanses' => function($q){

    $q->with(['room', 'movie']); // eager loading


and in GridView::$columns something like this:

'columns' => [

    ['class' => 'yii\grid\SerialColumn'],

    // ...


        'value' => function($model) {

            $cellData = [];

            foreach($model->seanses as $seanse){

                 $cellData[] = $seanse->movie->name;

                 $cellData[] = $seanse->room->number_room;


            return implode(', ', $cellData);



    // ...

    ['class' => 'yii\grid\ActionColumn'],



I have one more question yet. When is called validate function? I generated model/controller/view, and nowhere I don’t see called validate function for create/update method but it working. E.g rules include rule require/integer etc. and it is validated

@Pabloss, what exactly validated?

If I set $model->save(false) it’s still validates

Hmm. Can you post all code?