Example #1
0
 /**
  * Action - todo/update
  * update task 
  * 
  * @param int $id The task id
  * @return string
  */
 public function updateAction($id)
 {
     $models = $this->app['models'];
     //-----------------
     try {
         // Initialization
         $this->init(__CLASS__ . "/" . __FUNCTION__);
         // Create object newTask and set values
         $task = new Todo();
         $task->setApp($this->app);
         $task->setResolveValues($this->params);
         // use a validator to check the values
         $errorList = $this->validate($task);
         if ($errorList !== TRUE && count($errorList)) {
             $errMessage = $this->getMsgErrorValid($errorList);
             $this->app->abort(400, $errMessage);
         }
         $data = $models->load('Todo', 'updateTask', $task->getValues());
         return $this->sendJson($data);
     } catch (\Exception $exc) {
         return $this->errorAjax($exc);
     }
 }