I need to get a third-level relationship (I do not know if that’s q is spoken), but I’ll explain.
I have a table Area that is related to the Macropocesso table, Macropocesso table is also related to the Processo table.
But the in the Processo list (index.php) I need to show the column Area.
Is there any way to do this?
Initially I thought using the relationship that already exists between Area and Macroprocesso, since the Processo table is related to Macroprocesso.
My tests are:
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'macroprocesso.area.NOME',
'value' => function($data) {
yii\helpers\VarDumper::dump($data, 10, true);
//return $data->macroprocesso->area->NOME;
}
],
[
'label' => 'Macroprocesso',
'attribute' => 'MACROPROCESSO_ID',
'value' => 'macroprocesso.MACROPROCESSO',
],
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'label' => 'Área',
'value' => 'macroprocesso.area.NOME',
],
[
'label' => 'Macroprocesso',
'attribute' => 'MACROPROCESSO_ID',
'value' => 'macroprocesso.MACROPROCESSO',
],
I tried use viaTable() in my relationship, but didn’t work.
Follow my pastebin with 3 models http://pastebin.com/faQ0LzFr