I am new to yii. I have tried myself,googled and found that yii2 default CRUD generator Gii will not generate CRUD for tables which has many to many relations. Also found that yii achieves(not in the sense Gii) Many to Many via One to Many yiiDrills .
Now I am trying to emulate the same kind of default CRUD manually with the help of Github issue trail and stackoverflow trail. I am facing the below issues while trying this.
Issue-1 (Model class of the table with Many to Many relations): Not able to initialize the class ActiveDataProvider,
$query = TableA::find();
$dataProvider = new ActiveDataProvider([
'query' => $query->TableB(),
]);
Issue-2(View): Even if I were able to initialize it how to render it via GridView
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//How to give the column names like we give for one to many
/* Example */
'TableA.attr1',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
Also I would like to know if it is desired to create a Model class for the table with Many to Many relations to handle CRUD.
Thanks