I have a Yii2 advanced app with Dynagrid and with one column editable (http://demos.krajee.com/editable)
I wrote it on local PC and editable works fine.
I copied the files on my host and now I get Internal server error when trying to use Editable widget to update the value of the field.
Investigating showed me the place where error happens
POST http://.../backend/web/index.php?r=trackdata%2Findex 500 (Internal Server Error)
send @ jquery.js:9177
...
by clicking on this jquery.js I see :
xhr.send( options.hasContent && options.data || null ); with the red error flag
When introducing a console.log(xhr); before the xhr.send instruction I see :
response:"<pre>PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'yii\helpers\json' not found' ↵↵in .../backend/controllers/TrackdataController.php:63↵↵Stack trace:↵#0 [internal function]: yii\base\ErrorHandler->handleFatalError()↵#1 {main}</pre>"
responseText
So the reason is : Class yii\helpers\json not found But in my controller I use yii json helper as you can see in my Controller :
use yii\helpers\json;
...
if (Yii::$app->request->post('hasEditable'))
{
$trackId = Yii::$app->request->post('editableKey');
$model = Trackdata::findOne($trackId);
$out = Json::encode(['output'=>'', 'message'=>'']);
$post = [];
$posted = current($_POST['Trackdata']);
$post['Trackdata'] = $posted;
if ($model->load($post))
{
$model->save();
$output = '';
$out = Json::encode(['output'=>$output, 'message'=>'']);
}
echo $out;
return;
...
This is the view :
<?= DynaGrid::widget([
'columns' => [
...
[
'class' => 'kartik\grid\EditableColumn',
'attribute'=>'vu',
'editableOptions'=> function ($model, $key, $index) {
return [
'displayValueConfig' => [1 => 'Oui', 0 => 'Non'],
'displayValue' => [1 => 'Oui', 0 => 'Non'],
'data' => [1 => 'Oui', 0 => 'Non'],
'value' => 0,
'asPopover' => true,
'header' => 'Vu ',
'inputType' => Editable::INPUT_DROPDOWN_LIST,
];
}
],
...
I cannot see why I am getting this error only on the host and not on the local PC. Any help would be nice !