Example #1
0
 /**
  * @brief 商品模型添加/修改
  */
 public function model_update()
 {
     // 获取POST数据
     $attribute = IReq::get("attr");
     $spec = IReq::get("spec");
     $model_name = IReq::get("model_name");
     $model_id = IReq::get("model_id");
     //初始化Model类对象
     $modelObj = new Model();
     //校验数据
     if (!IValidate::required($model_name)) {
         //处理post数据,渲染到前台
         $result = $modelObj->postArrayChange($attribute, $spec);
         $this->data = array('id' => $model_id, 'name' => $model_name, 'model_attr' => $result['model_attr'], 'model_spec' => $result['model_spec']);
         $this->setRenderData($this->data);
         $this->redirect('model_edit', false);
         Util::showMessage('模型名称不能为空!');
         exit;
     }
     //更新模型数据
     $result = $modelObj->model_update($model_id, $model_name, $attribute, $spec);
     if ($result) {
         $this->redirect('model_list');
     } else {
         //处理post数据,渲染到前台
         $result = $modelObj->postArrayChange($attribute, $spec);
         $this->data = array('id' => $model_id, 'name' => $model_name, 'model_attr' => $result['model_attr'], 'model_spec' => $result['model_spec']);
         $this->setRenderData($this->data);
         $this->redirect('model_edit', false);
     }
 }
Example #2
0
 /**
  * @brief 商品模型添加/修改
  */
 public function model_update()
 {
     // 获取POST数据
     $model_id = IFilter::act(IReq::get("model_id"), 'int');
     $model_name = IFilter::act(IReq::get("model_name"));
     $attribute = IFilter::act(IReq::get("attr"));
     $spec = IFilter::act(IReq::get("spec"));
     //初始化Model类对象
     $modelObj = new Model();
     //更新模型数据
     $result = $modelObj->model_update($model_id, $model_name, $attribute, $spec);
     if ($result) {
         $this->redirect('model_list');
     } else {
         //处理post数据,渲染到前台
         $result = $modelObj->postArrayChange($attribute, $spec);
         $this->data = array('id' => $model_id, 'name' => $model_name, 'model_attr' => $result['model_attr'], 'model_spec' => $result['model_spec']);
         $this->setRenderData($this->data);
         $this->redirect('model_edit', false);
     }
 }