Php 如何将更新后的数据保存在yii2中的数据库中?
我已安装“使列可编辑” 工作正常,但更新的数据不存储在数据库中。如何将其存储在数据库中 index.phpPhp 如何将更新后的数据保存在yii2中的数据库中?,php,yii2,yii-extensions,Php,Yii2,Yii Extensions,我已安装“使列可编辑” 工作正常,但更新的数据不存储在数据库中。如何将其存储在数据库中 index.php [ 'class' => 'kartik\grid\EditableColumn', 'editableOptions' => [ 'header' => 'status', 'inputType' => Editabl
[
'class' => 'kartik\grid\EditableColumn',
'editableOptions' => [
'header' => 'status',
'inputType' => Editable::INPUT_TEXT,
'type' => 'danger',
'placement' => 'right',
'options' => [
'pluginOptions' => ['min' => 0, 'max' => 5000]
]
],
'attribute' => 'status',
'hAlign' => 'center',
'label' => 'Status',
'filterType' => GridView::FILTER_SELECT2,
'filter' => [ 'Present' => 'Present', 'Absent' => 'Absent', 'Leave' => 'Leave',],
'filterInputOptions' => ['placeholder' => 'search by status'],
'filterWidgetOptions' => [
'pluginOptions' => ['allowClear' => true],
],
],
public function actionIndex()
{
$searchModel = new AttendanceSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if(isset($_POST['hasEditable'])){
$staffindex=$_POST['editableIndex'];
$status = $_POST['Attendance'][$staffindex]['status'];
$staffid=$_POST['editableKey'];
//save attendence
return true;
}
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
控制器
[
'class' => 'kartik\grid\EditableColumn',
'editableOptions' => [
'header' => 'status',
'inputType' => Editable::INPUT_TEXT,
'type' => 'danger',
'placement' => 'right',
'options' => [
'pluginOptions' => ['min' => 0, 'max' => 5000]
]
],
'attribute' => 'status',
'hAlign' => 'center',
'label' => 'Status',
'filterType' => GridView::FILTER_SELECT2,
'filter' => [ 'Present' => 'Present', 'Absent' => 'Absent', 'Leave' => 'Leave',],
'filterInputOptions' => ['placeholder' => 'search by status'],
'filterWidgetOptions' => [
'pluginOptions' => ['allowClear' => true],
],
],
public function actionIndex()
{
$searchModel = new AttendanceSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if(isset($_POST['hasEditable'])){
$staffindex=$_POST['editableIndex'];
$status = $_POST['Attendance'][$staffindex]['status'];
$staffid=$_POST['editableKey'];
//save attendence
return true;
}
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
任何
update()
method?@Insane skull thanx其工作。任何update()
method?@Insane skull thanx其工作。