Tôi muốn thực hiện thao tác CRUD bằng Công cụ GII, nhưng tôi nhận được thông báo lỗi Missing required parameters: id
, khi tôi cố gắng lưu bài đăng của mình. điều khiểnYêu cầu không hợp lệ (# 400) - Thiếu tham số bắt buộc: id trong YII2
bài viết:
public function actionCreate()
{
$model = new Post();
if ($model->load(Yii::$app->request->post())) {
$model->post_create_time=date('Y-m-d h:m:s');
$model->save();
return $this->redirect(['view', 'id' => $model->id_post]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
Tại sao tôi luôn nhận được lỗi này?
Hiện mã của 'ActionView() '. – arogachev
@arogachev đây là 'actionView': ' actionView công khai ($ id) { trả về $ this-> render ('view', [ 'model' => $ this-> findModel ($ id) , ]); } ' –