1
我有Gangguan模型,我有在Gangguan模型id_registrasi(不是一個PK), 我想在我的gridView編輯id_registrasi使用可編輯,彈出窗口給出一個錯誤消息「內部服務器錯誤」但當我刷新頁面(F5)時,列已成功更改。 和問題是我不能處理該錯誤。 .. 這是我的控制器yii2可編輯的內部服務器錯誤
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;
}
,這是列
[
'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,
],
1.首先應啓用調試模式:Yii定義並使用常量YII_DEBUG和YII_ENV。他們被設置爲「真實」和「開發」。這是因爲基本的應用程序模板已經在[index.php](https://github.com/yiisoft/yii2-app-basic/blob/master/web/index.php)文件中以這種方式進行了準備。這個文件告訴我們,我們應該刪除生產模式下的生產線,即在生產機器上。然後這些常量默認設置爲'false'和'prod'。[[更多信息可以在定義常量和環境常量中找到](http://www.yiiframework.com/doc-2.0/guide-concept-conf –