A
A
Alexander2015-09-08 11:10:59
Yii
Alexander, 2015-09-08 11:10:59

hasManyToMany(viaTable) binding in yii2?

c99e2a2f9575490b889cb084587cb853.png

Model Film :
public function getActorName()
    {
        return $this->hasMany(Actor::className(), ['actor_id' => 'film_id'])
            ->viaTable('actor_film_mapping', ['actor_id' => 'film_id']);
    }
Во вью :
<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute' => 'actor_id',
                'value' => 'actorName.name'
            ],
            'film_id',
            'name',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

Error (not set) in ad-yii.local/admin/film/index . What am I doing wrong?? Filled in all fields correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2015-09-08
@webinar

You have an idea in the actorName.name array. Here he is cursing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question