A few things you can try here:
- Check if
$model->post_id null before using it.
See an example below.
$success=$model->save(); // if it false, it means there was an error var_dump($success); exit;
- Check if
save() successful before using it:
see below code
if($model->save()){ return $this->redirect(['view', 'id' => $model->id_post]); }else{
In addition, I would advise you to publish the code for the actionView and the Post class as well
source share