0

I am using yii2 grid view widget like below

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        [
            'attribute' => 'name',
            'visible' => empty($visbleValue) ? '1':'0',
            'value' => function($model){                   
                return $model->name;
            }
        ],         
        [   
            'attribute' => 'account',
            'visible' => empty($visbleValue) ? '0':'1',
            'value' => function($model){                
                return implode(', ', ArrayHelper::map($model->accounts, 'id', 'account_name'));
            }
        ],
        [
            'attribute' => 'Document',
            'visible' => empty($visbleValue) ? '1':'0',
            'value' => function($model, $index, $column) {
               return Document::findOne(['user_id' => $model->id,])->document_name;
            },
            'label' => 'Document',
        ],

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

This all are working fine, but i want prepare columns array values(attribute values like name,account,document) using model or controller, how to do that.

Controller

public function actionVerficationDetails()
{      
    $session = Yii::$app->session;
    $visbleValue= $session->get('visbleValue');
    $searchModel = new VerficationDetailsSearch();
    $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
    return $this->render('VerficationDetails', [
        'searchModel' => $searchModel,
        'dataProvider' => $dataProvider,
        'visbleValue' => $visbleValue,
    ]); 
}

Here i print dataprovider it will print some empty query objects, no data will come. Please help anyone.

praba
  • 105
  • 1
  • 3
  • 11
  • I hope i can help you,but the problem is about the technical terms in question , will you please make it simple ? What output or how the output you want to be in view page ? – Sumith Chalil Jun 28 '17 at 16:40
  • your question is not clear .. try explain better your need – ScaisEdge Jun 28 '17 at 17:33
  • Sorry for in convenience.Simply i want pass variable in grid view widget column like that **'columns' =>$variable** – praba Jun 29 '17 at 04:10

0 Answers0