I have Gangguan model, I have id_registrasi (not a PK) in Gangguan model, I want to edit id_registrasi in my gridView using editable, the pop up windows give an error message "Internal Server Error" but when I refresh page (F5), the column has successful changed. and the problem is i cant handle that error. .. this is my controller
if(Yii::$app->request->post('hasEditable')){
$Id = Yii::$app->request->post('editableKey');
$model1 = $this->findModel($Id);
$posted = current($_POST['Gangguan']);
$model1->id_registrasi = $posted['id_registrasi'];
$model1->save(false);
$output = $model1->id_registrasi;
$out = Json::encode(['output'=>$output, 'message'=>'']);
echo $out;
return;
}
and this is the column
[
'class' => 'kartik\grid\EditableColumn',
'attribute'=>'id_registrasi',
'hAlign' => 'top',
'vAlign' => 'middle',
'width'=>'100px',
'headerOptions' => ['class' => 'kv-sticky-column'],
'contentOptions' => ['class' => 'kv-sticky-column'],
'footerOptions' => ['class' => 'kv-sticky-column'],
'pageSummary' => true,
],
Use the following in your controller and it should be ok then.
use yii\helpers\json;