/** * 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, $name) { $users=UserChild::getNames(); $accounts=AccountChild::getNames(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST[$name])) { $model->attributes=$_POST[$name]; $model=$this->updateChangelog($model); if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, 'users'=>$users, 'accounts'=>$accounts, )); }
/** * 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($id) { $name = 'Contacts'; $model = $this->loadModel($id); $users=UserChild::getNames(); $accounts=AccountChild::getNames(); if(isset($_POST[$name])) { $temp=$model->attributes; $model->attributes=$_POST[$name]; $attributeLabels = ContactChild::attributeLabels(); if($model->address == $attributeLabels['address']) $model->address = ''; if($model->city == $attributeLabels['city']) $model->city = ''; if($model->state == $attributeLabels['state']) $model->state = ''; if($model->zipcode == $attributeLabels['zipcode']) $model->zipcode = ''; if($model->country == $attributeLabels['country']) $model->country = ''; $changes=$this->calculateChanges($temp,$model->attributes); $model=$this->updateChangelog($model,$changes); if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, 'users'=>$users, 'accounts'=>$accounts, )); }