Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. class UpdateAction extends CAction {
  4.  
  5.   /**
  6.    * Updates a particular model.
  7.    * If update is successful, the browser will be redirected to the 'view' page.
  8.    * @param integer $id the ID of the model to be updated
  9.    */
  10.   public function run($id) {
  11.     $model = $this->loadModel($id);
  12.  
  13.     // Uncomment the following line if AJAX validation is needed
  14.     // $this->performAjaxValidation($model);
  15.  
  16.     if (isset($_POST['User'])) {
  17.       $model->attributes = $_POST['User'];
  18.       if ('' == $model->password)
  19.         unset($model->password);
  20.       if ($model->save())
  21.         $this->getController()->redirect(array('view', 'id' => $model->id));
  22.     }
  23.  
  24.     $this->getController()->render('update', array('model' => $model,));
  25.   }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement