combine 2 columns from relational table into view

Hello all,

In my index.php file for a branches view, I have a relational table companies. companies has two columns I would like to show in 1 column of the grid view: company_name and company_reg_number.

Below the column has companiesCompany.company_name. Is there a way to get both company name and company_reg_number to display in one column.

Sort of like


companiesCompany.company_name . ' - ' . companiesCompany.company_reg_number ;


<?= GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'columns' => [

            ['class' => 'yii\grid\SerialColumn'],

            [

                'attribute'=>'companies_company_id',

                'value'=>'companiesCompany.company_name',

            ],


            //'companiesCompany.company_name',

            'branch_name',

            'branch_address',

            'branch_created_date',

            // 'branch_status',


            ['class' => 'yii\grid\ActionColumn'],

        ],

Anyone going to take pitty on me? ;)

you can use this :


        'columns'=>array(

...

        array(

            'class'=>'CDataColumn',

            'header'=>'user email and name ',

            'value'=>'$data->email." , ".$data->name',

        ),

),

also if you want more proccess in your data you can add your function to some where like components and use it like this :


        'columns'=>array(

...

        array(

            'class'=>'CDataColumn',

            'header'=>'user email and name ',

            'value'=>'Yii:app()->comment->getUserNameAndEmailForDetectedComment($data->id)',

        ),

),

Perfect!! Thank you!!