/** * 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 actionAjaxUpdate($id) { $model = $this->loadModel($id); $accountController = new AccountController($model->ID_Account); $account = $accountController->loadModel($model->ID_Account); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); $this->performAjaxValidation($account); if (isset($_POST['Student']) && isset($_POST['Account'])) { $model->attributes = $_POST['Student']; $account->attributes = $_POST['Account']; if ($account->validate() && $account->save()) { if ($model->validate() && $model->save()) { echo '<script type="text/javascript">location.reload()</script>'; } //$this->redirect(array('index','id'=>$model->ID)); } } $this->renderPartial('_form', array('model' => $model, 'account' => $account), false, true); }
/** * 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 actionAjaxUpdate($id) { $model = $this->loadModel($id); $accountController = new AccountController($model->ID_Account); $account = $accountController->loadModel($model->ID_Account); $avatar = $model->Avatar; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); $this->performAjaxValidation($account); if (isset($_POST['Users']) && isset($_POST['Account'])) { $account->attributes = $_POST['Account']; $model->attributes = $_POST['Users']; $model->Avatar = CUploadedFile::getInstance($model, 'Avatar'); if (!empty($model->Avatar)) { $model->Avatar->saveAs(Yii::getPathOfAlias('webroot') . '/images/avatars/' . $model->Avatar->name); } else { $model->Avatar = $avatar; } if ($account->validate() && $account->save()) { if ($account->validate() && $model->save()) { echo '<script type="text/javascript">location.reload()</script>'; } } //$this->redirect(array('index','id'=>$model->ID)); } $this->renderPartial('_form', array('model' => $model, 'account' => $account), false, true); }