A
A
AlexAll2019-04-14 12:46:38
Yii
AlexAll, 2019-04-14 12:46:38

How to display data in GridView from hasMany connection through a linked table in yii2?

I'm trying to display data in a GridView from a hasMany connection via a linked table
Here is the connection

public function getRoomOptions()
    {
                return $this->hasMany(Options::className(), ['id' => 'options_id'])
            ->viaTable('room_options', ['room_id' => 'id']);
    }

In the view itself I do this
$options = $model->roomOptions;

   echo GridView::widget([
        'dataProvider' => $options,
       'summary' => false,

/// ......

It gives an error
Call to a member function getCount() on array
As I understand it, because the connection produces an array and not an object, how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2019-04-14
@inoise

Make a render one of the columns and write your handler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question