Question:
I have 2 models, user model and user profile model, both are related with primary and forien key user_id, user table has fields id,username, password, email etc user_profile table has filed id, user_id, company, phone etc
I have created gridview in user view. I am using kartik EditableColumn, I want to edit user profile table field company from user gridview.
What I have done so far. Please check code what I have done.
please note: it is portion of code i am showing here, and I think it is enough to understand. if you like to see more i will edit question.
use yii\helpers\Url;
$gridColumns = [
[
'class' => 'kartik\grid\EditableColumn',
'attribute' => 'company',
'pageSummary' => true,
'readonly' => false,
'value' => 'userProfiles.company',
'content' => function($data,$model){return '<div class="text_content">'.htmlentities($data->userProfiles->company).'</div>';},
'editableOptions' => [
'header' => 'Company',
'inputType' => kartik\editable\Editable::INPUT_TEXT,
'options' => [
'pluginOptions' => [
]
]
],
],
];
//note: used all namespace
Pjax::begin();
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'class' => 'kartik\grid\EditableColumn',
'responsive'=>true,
'hover'=>true,
'pjax'=>true,
'tableOptions'=>['class'=>'table table-bordered table-striped dataTable table-hover'],
'summaryOptions' => ['class' =>'dataTables_info'],
'layout'=>"{items}\n<div class='row' style='margin:0.1%'>
<div class='col-sm-5'>
{summary}
</div>
<div class='col-sm-7'>
<div class='dataTables_paginate paging_simple_numbers'>{pager}</div>
</div>
</div>",
'columns' => $gridColumns,
]); Pjax::end();
Problem is
When I click on company value it shows me blank. please check image.