Commits

christiansalazar  committed ab432e7

FIXED ISSUE #57 - validacion no estaba aplicandose al momento de crear un campo personalizado.

  • Participants
  • Parent commits 5802683

Comments (0)

Files changed (1)

File controllers/UiController.php

     public function actionFieldsAdminUpdate($id)
     {
         $model = Yii::app()->user->um->loadFieldById($id);
-        if ($model != null) {
-            if (isset($_POST[CrugeUtil::config()->postNameMappings['CrugeField']])) {
-                $model->attributes = $_POST[CrugeUtil::config()->postNameMappings['CrugeField']];
-                if ($model->save()) {
-                    $this->redirect(array('fieldsadminlist'));
-                }
-            }
-            $this->render("fieldsadminupdate", array('model' => $model));
-        }
+		if($model != null){
+			$this->_fieldAdminForm($model);
+		}else
+			throw new CrugeException("Identificador de campo es invalido");
     }
 
     public function actionFieldsAdminCreate()
     {
         $model = Yii::app()->user->um->createEmptyField();
+		$this->_fieldAdminForm($model);
+    }
+	
+	private function _fieldAdminForm($model){
         if (isset($_POST[CrugeUtil::config()->postNameMappings['CrugeField']])) {
             $model->attributes = $_POST[CrugeUtil::config()->postNameMappings['CrugeField']];
-            if ($model->insert()) {
+            if ($model->save()) {
                 $this->redirect(array('fieldsadminlist'));
             }
         }
         $this->render("fieldsadminupdate", array('model' => $model));
-    }
+	}
 
     public function actionFieldsAdminDelete($id)
     {