getErrors() публичный Метод

获取所有的错误信息
public getErrors ( )
Пример #1
0
 public function actionUpdate($id)
 {
     $model = $this->loadBiz(trim($id));
     $model->setScenario('sell');
     $this->performAjaxValidation($model);
     if (!empty($_POST)) {
         $model->attributes = $_POST['ARBiz'];
         //            dump($_FILES);
         //            控制器中使用实例如下:
         $upload = new FileUpload(array($model, 'license_photo'), 'upload/groupon');
         //model处理文件上传  $upload = new FileUpload(array($model,'pic'),'upload/goods');
         if (!$upload->isNull()) {
             if ($filename = $upload->save()) {
                 $model->license_photo = $filename;
                 //                      dump($filename);
             } else {
                 print_r($upload->getErrors());
                 throw new CHttpException('300', '文件上传失败');
             }
         }
         //            dump($model->attributes);
         if ($model->save()) {
             //                $return_url = $_POST['return_url'];
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Пример #2
0
 public function actionUpdate($id)
 {
     $model = ARGroupon::model()->findByPk($id);
     if ($model == null) {
         $this->go('该商品不存在', Yii::app()->request->urlReferrer);
     }
     $model->setScenario('sell');
     $this->performAjaxValidation($model);
     if (!empty($_POST['ARGroupon'])) {
         //            dump($_FILES);
         //            dump($_POST);exit;
         $model->attributes = $_POST['ARGroupon'];
         if ($model->validate()) {
             $fileUpload = new FileUpload(array($model, 'image'), 'upload/groupon');
             if (!$fileUpload->isNull()) {
                 $filename = $fileUpload->save();
                 if ($filename) {
                     $model->image = $filename;
                 } else {
                     dump($fileUpload->getErrors());
                     throw new CHttpException(300, '图片上传出错');
                 }
             }
             $model->begin_time = strtotime($model->begin_time);
             $model->end_time = strtotime($model->end_time);
             $model->expire_time = strtotime($model->expire_time);
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', '商品修改成功');
                 //                    $url = $_POST['return_url'];
                 //                    $this->go('商品修改成功', $url, 'success');
             }
         }
     }
     $this->render('update', array('model' => $model));
 }