/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Specification();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Specification'])) {
         $model->attributes = $_POST['Specification'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * 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)
 {
     $model = $this->loadModel($id);
     if ($model == null) {
         $model = new Specification();
         $model->setIsNewRecord(true);
     }
     //var_dump($model);die();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     //echo "string"; die();
     if (isset($_POST['Specification'])) {
         $model->attributes = $_POST['Specification'];
         if ($model->save()) {
             echo "saved";
             $this->render('success');
         }
     }
     $this->render('update', array('model' => $model));
 }
示例#3
0
 /**
  * 规格创建
  */
 public function actionCreate()
 {
     if ($_POST) {
         $Specification = new Specification();
         $SpecValues = new SpecValues();
         $Specification->attributes = $this->post('Spec');
         $spec_value_attributes = $this->post('SpecValue');
         if (!$Specification->save()) {
             $this->message('error', CHtml::errorSummary($Specification), $this->createUrl('index'));
         }
         $spec_id = Yii::app()->db->getLastInsertID();
         $result = $SpecValues->SpecValuesAdd($spec_id, $spec_value_attributes);
         if ($result) {
             $this->message('success', '新增成功', $this->createUrl('index'));
         } else {
             $this->message('error', CHtml::errorSummary($SpecValues), $this->createUrl('index'));
         }
     }
     $this->render('create');
 }