I am using following code in my controller. Have a look into that and let me know about the issue.
$model = new Model;
if (isset($_POST['Model'])) {
if ($model->save) {
$this->redirect(array('view','id'=>$model->id));
}
}
I can assume, you can try following change:
$model= new Model();
if(isset($_POST['Model'])){
$model->attributes = $POST['Model']
if($model->save)
$this->redirect(array('view','id'=>$model->id));
}
$model= new Model();
if(Yii::app()->request->isPostRequest)
{
$model->attributes = $_POST['Model']
if($model->save)
$this->redirect(array('view','id'=>$model->id));
}
There are a few issues with your code. First you are not setting the values of the model. Second. save is a function, not a variable
$model = new Model;
if (isset($_POST['Model'])) {
// Fix 1. Save the details from the form to your model
$model->setAttributes = $_POST['Model'];
// Fix 2. Save is a function. Notice the ()
if ($model->save()) {
$this->redirect(array('view','id'=>$model->id));
}
}