/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate() { $model = new Used(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $flag = 0; if (isset($_POST['product_id'], $_POST['used_flag'])) { $model = $model->loadUsedModel($_POST['product_id']); //$model->attributes=$_POST['Wishlist']; if ($model == null) { $model = new Used(); $model->setIsNewRecord(TRUE); } $model->used_flag = $_POST['used_flag'] ? 0 : 1; $model->product_id = $_POST['product_id']; if ($model->save()) { echo "saved"; // echo "</pre>"; echo "post"; var_dump($model); die(); $this->redirect(array('view', 'id' => $model->used_id)); } } $this->render('update', array('model' => $model, 'productId' => $model->product_id, 'used_flag' => $flag)); }