コード例 #1
0
 public function actionWrite()
 {
     if (isset($_POST['Addresstype'])) {
         $messages = $this->ValidateData(array(array($_POST['Addresstype']['addresstypename'], 'emptyaddresstypename', 'emptystring')));
         if ($messages == '') {
             //$dataku->attributes=$_POST['Addresstype'];
             if ((int) $_POST['Addresstype']['addresstypeid'] > 0) {
                 $model = $this->loadModel($_POST['Addresstype']['addresstypeid']);
                 $model->addresstypename = $_POST['Addresstype']['addresstypename'];
                 $model->recordstatus = $_POST['Addresstype']['recordstatus'];
             } else {
                 $model = new Addresstype();
                 $model->attributes = $_POST['Addresstype'];
             }
             try {
                 if ($model->save()) {
                     $this->DeleteLock($this->menuname, $_POST['Addresstype']['addresstypeid']);
                     $this->GetSMessage('coatinsertsuccess');
                 } else {
                     $this->GetMessage($model->getErrors());
                 }
             } catch (Exception $e) {
                 $this->GetMessage($e->getMessage());
             }
         }
     }
 }