php
you can set the EditableColumn::editableOptions['formOptions']['action'] to point to the action below
i.e. /site/editbook for the example below
use kartik\grid\EditableColumnAction;
use yii\web\Controller;
use yii\helpers\ArrayHelper;
use app\models\Book;
class SiteController extends Controller
{
public function actions()
{
return array_replace_recursive(parent::actions(), [
'editbook' => [ // identifier for your editable column action
'class' => EditableColumnAction::className(), // action class name
'modelClass' => Book::className(), // the model for the record being edited
'scenario' => Model::SCENARIO_DEFAULT, // model scenario assigned before validation & update
'outputValue' => function ($model, $attribute, $key, $index) {
return (int) $model->$attribute / 100; // return a calculated output value if desired
},
'outputMessage' => function($model, $attribute, $key, $index) {
return ''; // any custom error to return after model save
},
'showModelErrors' => true, // show model validation errors after save
'errorOptions' => ['header' => ''] // error summary HTML options
'postOnly' => true,
'ajaxOnly' => true,
'findModel' => function($id, $action) },
'checkAccess' => function($action, $model) }
]
]);
}
}
public function actions() { return ArrayHelper::merge(parent::actions(), ['toggle' => ['class' => ToggleAction::className(), 'modelClass' => OptionsList::className(), 'setFlash' => true, 'attribute' => 'active', 'primaryKey' => 'id'], 'editsort' => ['class' => EditableColumnAction::className(), 'modelClass' => OptionsList::className(), 'outputValue' => function ($model, $attribute, $key, $index) { return (int) $model->{$attribute}; // return any custom output value if desired }, 'outputMessage' => function ($model, $attribute, $key, $index) { return ''; // any custom error to return after model save }, 'showModelErrors' => true, 'errorOptions' => ['header' => ''], 'postOnly' => true, 'ajaxOnly' => true]]); }
public function actions() { return ArrayHelper::merge(parent::actions(), ['update' => ['class' => EditableColumnAction::className(), 'modelClass' => Language::className(), 'findModel' => function ($id, $action) { $language = Language::findOne($id); $language->scenario = 'update'; return $language; }, 'outputValue' => function ($model, $attribute, $key, $index) { return $model->{$attribute}; }, 'outputMessage' => function ($model, $attribute, $key, $index) { return ''; }, 'showModelErrors' => true, 'errorOptions' => ['header' => '']]]); }